Results 1 to 14 of 14

Thread: Local Languages

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2000
    Posts
    44

    Local Languages

    Hello every one

    I want to get a list of languages that are installed in my computer,
    but only those whome appear in the 'Input Locals' list in the Regional Settings.

    Is there any way to do this?

    Please HELP!!!

    Thanks,
    Shuly.

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    Play around with this and the language constants
    VB Code:
    1. Private Declare Function GetLocaleInfo Lib "kernel32" Alias "GetLocaleInfoA" (ByVal Locale As Long, ByVal LCType As Long, ByVal lpLCData As String, ByVal cchData As Long) As Long
    2. Private Declare Function SetLocaleInfo Lib "kernel32" Alias "SetLocaleInfoA" (ByVal Locale As Long, ByVal LCType As Long, ByVal lpLCData As String) As Boolean
    3. Private Declare Function GetUserDefaultLCID% Lib "kernel32" ()
    4.  
    5. Private Const LOCALE_ICENTURY = &H24
    6. Private Const LOCALE_ICOUNTRY = &H5
    7. Private Const LOCALE_ICURRDIGITS = &H19
    8. Private Const LOCALE_ICURRENCY = &H1B
    9. Private Const LOCALE_IDATE = &H21
    10. Private Const LOCALE_IDAYLZERO = &H26
    11. Private Const LOCALE_IDEFAULTCODEPAGE = &HB
    12. Private Const LOCALE_IDEFAULTCOUNTRY = &HA
    13. Private Const LOCALE_IDEFAULTLANGUAGE = &H9
    14. Private Const LOCALE_IDIGITS = &H11
    15. Private Const LOCALE_IINTLCURRDIGITS = &H1A
    16. Private Const LOCALE_ILANGUAGE = &H1
    17. Private Const LOCALE_ILDATE = &H22
    18. Private Const LOCALE_ILZERO = &H12
    19. Private Const LOCALE_IMEASURE = &HD
    20. Private Const LOCALE_IMONLZERO = &H27
    21. Private Const LOCALE_INEGCURR = &H1C
    22. Private Const LOCALE_INEGSEPBYSPACE = &H57
    23. Private Const LOCALE_INEGSIGNPOSN = &H53
    24. Private Const LOCALE_INEGSYMPRECEDES = &H56
    25. Private Const LOCALE_IPOSSEPBYSPACE = &H55
    26. Private Const LOCALE_IPOSSIGNPOSN = &H52
    27. Private Const LOCALE_IPOSSYMPRECEDES = &H54
    28. Private Const LOCALE_ITIME = &H23
    29. Private Const LOCALE_ITLZERO = &H25
    30. Private Const LOCALE_NOUSEROVERRIDE = &H80000000
    31. Private Const LOCALE_S1159 = &H28
    32. Private Const LOCALE_S2359 = &H29
    33. Private Const LOCALE_SABBREVCTRYNAME = &H7
    34. Private Const LOCALE_SABBREVDAYNAME1 = &H31
    35. Private Const LOCALE_SABBREVDAYNAME2 = &H32
    36. Private Const LOCALE_SABBREVDAYNAME3 = &H33
    37. Private Const LOCALE_SABBREVDAYNAME4 = &H34
    38. Private Const LOCALE_SABBREVDAYNAME5 = &H35
    39. Private Const LOCALE_SABBREVDAYNAME6 = &H36
    40. Private Const LOCALE_SABBREVDAYNAME7 = &H37
    41. Private Const LOCALE_SABBREVLANGNAME = &H3
    42. Private Const LOCALE_SABBREVMONTHNAME1 = &H44
    43. Private Const LOCALE_SCOUNTRY = &H6
    44. Private Const LOCALE_SCURRENCY = &H14
    45. Private Const LOCALE_SDATE = &H1D
    46. Private Const LOCALE_SDAYNAME1 = &H2A
    47. Private Const LOCALE_SDAYNAME2 = &H2B
    48. Private Const LOCALE_SDAYNAME3 = &H2C
    49. Private Const LOCALE_SDAYNAME4 = &H2D
    50. Private Const LOCALE_SDAYNAME5 = &H2E
    51. Private Const LOCALE_SDAYNAME6 = &H2F
    52. Private Const LOCALE_SDAYNAME7 = &H30
    53. Private Const LOCALE_SDECIMAL = &HE
    54. Private Const LOCALE_SENGCOUNTRY = &H1002
    55. Private Const LOCALE_SENGLANGUAGE = &H1001
    56. Private Const LOCALE_SGROUPING = &H10
    57. Private Const LOCALE_SINTLSYMBOL = &H15
    58. Private Const LOCALE_SLANGUAGE = &H2
    59. Private Const LOCALE_SLIST = &HC
    60. Private Const LOCALE_SLONGDATE = &H20
    61. Private Const LOCALE_SMONDECIMALSEP = &H16
    62. Private Const LOCALE_SMONGROUPING = &H18
    63. Private Const LOCALE_SMONTHNAME1 = &H38
    64. Private Const LOCALE_SMONTHNAME10 = &H41
    65. Private Const LOCALE_SMONTHNAME11 = &H42
    66. Private Const LOCALE_SMONTHNAME12 = &H43
    67. Private Const LOCALE_SMONTHNAME2 = &H39
    68. Private Const LOCALE_SMONTHNAME3 = &H3A
    69. Private Const LOCALE_SMONTHNAME4 = &H3B
    70. Private Const LOCALE_SMONTHNAME5 = &H3C
    71. Private Const LOCALE_SMONTHNAME6 = &H3D
    72. Private Const LOCALE_SMONTHNAME7 = &H3E
    73. Private Const LOCALE_SMONTHNAME8 = &H3F
    74. Private Const LOCALE_SMONTHNAME9 = &H40
    75. Private Const LOCALE_SMONTHOUSANDSEP = &H17
    76. Private Const LOCALE_SNATIVECTRYNAME = &H8
    77. Private Const LOCALE_SNATIVEDIGITS = &H13
    78. Private Const LOCALE_SNATIVELANGNAME = &H4
    79. Private Const LOCALE_SNEGATIVESIGN = &H51
    80. Private Const LOCALE_SPOSITIVESIGN = &H50
    81. Private Const LOCALE_SSHORTDATE = &H1F
    82. Private Const LOCALE_STHOUSAND = &HF
    83. Private Const LOCALE_STIME = &H1E
    84. Private Const LOCALE_STIMEFORMAT = &H1003
    85.  
    86. Private Sub GetRegionalSettings() ' Retrieve the regional setting
    87.  
    88.       Dim Symbol As String
    89.       Dim iRet1 As Long
    90.       Dim iRet2 As Long
    91.       Dim lpLCDataVar As String
    92.       Dim Pos As Integer
    93.       Dim Locale As Long
    94.      
    95.       Locale = GetUserDefaultLCID()
    96.  
    97. 'LOCALE_SDATE is the constant for the date separator
    98. 'as stated in declarations
    99. 'for any other locale setting just change the constant
    100.  
    101. 'Function can also be re-written to take the
    102. 'locale symbol being requested as a parameter
    103.      
    104.       iRet1 = GetLocaleInfo(Locale, LOCALE_SDATE, _
    105.       lpLCDataVar, 0)
    106.       Symbol = String$(iRet1, 0)
    107.      
    108.       iRet2 = GetLocaleInfo(Locale, LOCALE_SDATE, Symbol, iRet1)
    109.       Pos = InStr(Symbol, Chr$(0))
    110.       If Pos > 0 Then
    111.            Symbol = Left$(Symbol, Pos - 1)
    112.            MsgBox "Regional Setting = " + Symbol
    113.       End If
    114.  
    115. End Sub
    116.  
    117. Private Sub SetRegionalSettings() 'Change the regional setting
    118.  
    119.       Dim Symbol As String
    120.       Dim iRet As Long
    121.       Dim Locale As Long
    122.      
    123. 'LOCALE_SDATE is the constant for the date separator
    124. 'as stated in declarations
    125. 'for any other locale setting just change the constant
    126.  
    127. 'Function can also be re-written to take the
    128. 'locale information being set as a parameter
    129.  
    130.       Locale = GetUserDefaultLCID() 'Get user Locale ID
    131.       Symbol = "-" 'New character for the locale
    132.       iRet = SetLocaleInfo(Locale, LOCALE_SDATE, Symbol)
    133.      
    134. End Sub

  3. #3
    Frenzied Member numtel's Avatar
    Join Date
    Apr 2000
    Location
    CA
    Posts
    1,163
    are you talkin programmin languages or spoken languages?

  4. #4

    Thread Starter
    Member
    Join Date
    Jun 2000
    Posts
    44

    Local Languages

    Thanks for the code, but It still doesn't help me to find the .list of the usable (Spoken) languages, that are chosen in the list of the 'Input Locals' Tab.

    Shuly

  5. #5
    Frenzied Member MerrionComputin's Avatar
    Join Date
    Apr 2001
    Location
    Dublin, Ireland
    Posts
    1,616
    The ApiSystem class exports a list of InstalledLocales that you could enumerate thus:


    Dim apiLink As New EventVB.ApiFunctions

    Dim lcThis As EventVB.ApiLocale

    For Each lcThis In apiLink.InstalledLocales
    Debug.Print lcThis.LocalLanguageName
    Next lcThis



    You can also print the English version of the language name with the .EnglishLanguageName (i.e. "Spanish" rather than "Espagnol")

    HTH,
    Duncan

  6. #6

    Thread Starter
    Member
    Join Date
    Jun 2000
    Posts
    44

    Local Languages

    My project does not recognize the class EventVb.

    Is there any refrence I should give my vb project?

    Thanks
    Shuly.

  7. #7
    Frenzied Member MerrionComputin's Avatar
    Join Date
    Apr 2001
    Location
    Dublin, Ireland
    Posts
    1,616

    Missing links...

    The EventVB.dll and it's compiled help file will be needed.

    I'd also recommend you read some of the online help, such as the overview and the help for the ApiLocale class.

    HTH,
    Duncan
    ----8<---------------------------------------
    NEW - The .NET printer queue monitor component
    ----8<---------------------------------------
    Now with Examples of use

  8. #8

    Thread Starter
    Member
    Join Date
    Jun 2000
    Posts
    44

    EventVB

    In the help file its written that I should link to stdole2.tlb, well I have a link to that file and also to microsoft dao 3.51, but it still does not recognize the eventVB.

    I tried to link to the eventVB.dll but for some reson when I open the browse of the refrence window and I go to the localtion of that dll, it doesn't show the dll, even if I select All Files.

    I noticed my version of stdole2.tlb is older than the one is mentiond in the help file, does it make a diffrent?
    My version is 2.40.4277.

    What should I do now?

    Thanks,

    Shuly.

  9. #9
    Frenzied Member MerrionComputin's Avatar
    Join Date
    Apr 2001
    Location
    Dublin, Ireland
    Posts
    1,616
    Try using REGSVR32.exe to register it.

    i.e. From a dos prompt, CD to the directory where you have downloaded EventVB.dll and do:

    REGSVR32.exe EventVB.dll

    Thereafter it should appear in your VB references as MCL Event Handler.

    Note that the DLL requires the VB5 runtimes to work. If you do not have these you will need to download them from Microsoft Developer Network

    HTH,
    Duncan
    ----8<---------------------------------------
    NEW - The .NET printer queue monitor component
    ----8<---------------------------------------
    Now with Examples of use

  10. #10

    Thread Starter
    Member
    Join Date
    Jun 2000
    Posts
    44

    Post Local Languages

    The programs runs now, thank you very much.

    but what I wanted (which I suppose was not clear engouf) is the list of the languages that appear in the task bar.

    Can I get this list??

    thanks again,
    Shuly.

  11. #11
    Frenzied Member MerrionComputin's Avatar
    Join Date
    Apr 2001
    Location
    Dublin, Ireland
    Posts
    1,616
    Aha - that's different...

    What you need to do is call the API:
    Declare Function GetKeyboardLayoutList Lib "user32" Alias "GetKeyboardLayoutList" (ByVal nBuff As Long, lpList As Long) As Long

    This returns an array of keyboard handles that represent the keyboards installed on the system.

    First, you need to size the array and then fill it thus:

    Dim lRet As Long
    Dim hklList(1) As Long

    lRet = GetKeyboardList(0,hkList(1))
    Redim hkList(1 To lRet) As Long

    lRet = GetKeyboardList(lRet, hkList(1))
    ----8<---------------------------------------
    NEW - The .NET printer queue monitor component
    ----8<---------------------------------------
    Now with Examples of use

  12. #12
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744
    You can actually get all installed and supported locales on your machine by using EnumSystemLocales. Add a module to your project and copy this code to the module:
    VB Code:
    1. Public Declare Sub CopyMemory Lib "KERNEL32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
    2. Public Declare Function GetSystemDefaultLCID Lib "KERNEL32" () As Long
    3. Public Declare Function GetLocaleInfo Lib "KERNEL32" Alias "GetLocaleInfoA" (ByVal Locale As Long, ByVal LCType As Long, ByVal lpLCData As String, ByVal cchData As Long) As Long
    4. Public Declare Function EnumSystemLocales Lib "KERNEL32" Alias "EnumSystemLocalesA" (ByVal lpLocaleEnumProc As Long, ByVal dwFlags As Long) As Long
    5. Public Const LOCALE_SLANGUAGE       As Long = &H2
    6. Public Const LOCALE_SABBREVLANGNAME As Long = &H3
    7. Public Const LCID_INSTALLED         As Long = &H1
    8. Public Const LCID_SUPPORTED         As Long = &H2
    9. Public Const LCID_ALTERNATE_SORTS   As Long = &H4
    10.  
    11.  
    12. Public Function EnumSystemLocalesProc(p_lngLocaleType As Long) As Long
    13.    Dim strLocaleBuffer As String
    14.    Dim strLocaleName As String
    15.    Dim strLocaleAbbr As String
    16.    Dim intPos As Integer
    17.    Dim lngLocale As Long
    18.  
    19.      
    20.    strLocaleBuffer = Space$(32)
    21.    
    22.    CopyMemory ByVal strLocaleBuffer, p_lngLocaleType, ByVal Len(strLocaleBuffer)
    23.    
    24.    intPos = InStr(strLocaleBuffer, vbNullChar)
    25.    
    26.    If intPos Then
    27.       strLocaleBuffer = Left$(strLocaleBuffer, intPos - 1)
    28.      
    29.      'last 4 chars are the LocaleID identifier(in Hex)
    30.       strLocaleBuffer = (Right$(strLocaleBuffer, 4))
    31.      
    32.      'convert the string to a long
    33.       lngLocale = CLng("&H" & strLocaleBuffer)
    34.      
    35.      'get locale info
    36.       strLocaleName = GetUserLocaleInfo(lngLocale, LOCALE_SLANGUAGE)
    37.       strLocaleAbbr = GetUserLocaleInfo(lngLocale, LOCALE_SABBREVLANGNAME)
    38.    End If
    39.    
    40.    Debug.Print strLocaleBuffer & vbTab & lngLocale & vbTab & strLocaleAbbr & vbTab & strLocaleName
    41.    
    42.    'return 1 to continue enumeration
    43.    EnumSystemLocalesProc = 1
    44.    
    45. End Function
    46. Public Function GetUserLocaleInfo(ByVal p_lngLocaleID As Long, ByVal p_lngLocaleType As Long) As String
    47.     Dim strBuffer As String
    48.     Dim lngRetVal As Long
    49.  
    50.    
    51.     strBuffer = Space(500)
    52.     lngRetVal = GetLocaleInfo(p_lngLocaleID, p_lngLocaleType, strBuffer, Len(strBuffer))
    53.    
    54.     If lngRetVal Then
    55.         'lngRetVal holds the size of the string
    56.         'including the terminating null
    57.         GetUserLocaleInfo = Left$(strBuffer, lngRetVal - 1)
    58.     End If
    59. End Function
    60. Private Sub GetAllLocales()
    61.     Debug.Print "Installed Locales"
    62.    Call EnumSystemLocales ( AddressOf EnumSystemLocalesProc,  LCID_INSTALLED)
    63.    Debug.Print vbCrLf & "Supported Locales"
    64.    Call EnumSystemLocales(AddressOf EnumSystemLocalesProc, LCID_SUPPORTED)
    65. End Sub
    Then call the function like:

    Call GetAllLocales

    It will list all locales(supported and installed) in the immediate window.

  13. #13
    Frenzied Member MerrionComputin's Avatar
    Join Date
    Apr 2001
    Location
    Dublin, Ireland
    Posts
    1,616
    Indeed - th much how the ApiSystem.InstalledLocales collection is created but I believe the questioner wants the installed keyboard layouts.

    For example, on my PC there are 46 installed locales but only 10 installed keyboard layouts. The little indicator in the system tray allows switching between them and doing so sends a WM_INPUTLANGUAGECHANGE message to be sent to the top level window of the foreground thread.

    For this the GetKeyboardLayoutList() API call is used.
    ----8<---------------------------------------
    NEW - The .NET printer queue monitor component
    ----8<---------------------------------------
    Now with Examples of use

  14. #14

    Thread Starter
    Member
    Join Date
    Jun 2000
    Posts
    44

    Local Languages

    Well, MerrionComputin is right and was very helpful, thanks.

    but now I have two long numbers that indicates the languages,
    How can I get the name of the languages?

    Thanks,
    Shuly.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width