PDA

Click to See Complete Forum and Search --> : Local Languages


shuly
Jan 3rd, 2002, 06:49 AM
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.

Hack
Jan 3rd, 2002, 06:59 AM
Play around with this and the language constantsPrivate 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
Private Declare Function SetLocaleInfo Lib "kernel32" Alias "SetLocaleInfoA" (ByVal Locale As Long, ByVal LCType As Long, ByVal lpLCData As String) As Boolean
Private Declare Function GetUserDefaultLCID% Lib "kernel32" ()

Private Const LOCALE_ICENTURY = &H24
Private Const LOCALE_ICOUNTRY = &H5
Private Const LOCALE_ICURRDIGITS = &H19
Private Const LOCALE_ICURRENCY = &H1B
Private Const LOCALE_IDATE = &H21
Private Const LOCALE_IDAYLZERO = &H26
Private Const LOCALE_IDEFAULTCODEPAGE = &HB
Private Const LOCALE_IDEFAULTCOUNTRY = &HA
Private Const LOCALE_IDEFAULTLANGUAGE = &H9
Private Const LOCALE_IDIGITS = &H11
Private Const LOCALE_IINTLCURRDIGITS = &H1A
Private Const LOCALE_ILANGUAGE = &H1
Private Const LOCALE_ILDATE = &H22
Private Const LOCALE_ILZERO = &H12
Private Const LOCALE_IMEASURE = &HD
Private Const LOCALE_IMONLZERO = &H27
Private Const LOCALE_INEGCURR = &H1C
Private Const LOCALE_INEGSEPBYSPACE = &H57
Private Const LOCALE_INEGSIGNPOSN = &H53
Private Const LOCALE_INEGSYMPRECEDES = &H56
Private Const LOCALE_IPOSSEPBYSPACE = &H55
Private Const LOCALE_IPOSSIGNPOSN = &H52
Private Const LOCALE_IPOSSYMPRECEDES = &H54
Private Const LOCALE_ITIME = &H23
Private Const LOCALE_ITLZERO = &H25
Private Const LOCALE_NOUSEROVERRIDE = &H80000000
Private Const LOCALE_S1159 = &H28
Private Const LOCALE_S2359 = &H29
Private Const LOCALE_SABBREVCTRYNAME = &H7
Private Const LOCALE_SABBREVDAYNAME1 = &H31
Private Const LOCALE_SABBREVDAYNAME2 = &H32
Private Const LOCALE_SABBREVDAYNAME3 = &H33
Private Const LOCALE_SABBREVDAYNAME4 = &H34
Private Const LOCALE_SABBREVDAYNAME5 = &H35
Private Const LOCALE_SABBREVDAYNAME6 = &H36
Private Const LOCALE_SABBREVDAYNAME7 = &H37
Private Const LOCALE_SABBREVLANGNAME = &H3
Private Const LOCALE_SABBREVMONTHNAME1 = &H44
Private Const LOCALE_SCOUNTRY = &H6
Private Const LOCALE_SCURRENCY = &H14
Private Const LOCALE_SDATE = &H1D
Private Const LOCALE_SDAYNAME1 = &H2A
Private Const LOCALE_SDAYNAME2 = &H2B
Private Const LOCALE_SDAYNAME3 = &H2C
Private Const LOCALE_SDAYNAME4 = &H2D
Private Const LOCALE_SDAYNAME5 = &H2E
Private Const LOCALE_SDAYNAME6 = &H2F
Private Const LOCALE_SDAYNAME7 = &H30
Private Const LOCALE_SDECIMAL = &HE
Private Const LOCALE_SENGCOUNTRY = &H1002
Private Const LOCALE_SENGLANGUAGE = &H1001
Private Const LOCALE_SGROUPING = &H10
Private Const LOCALE_SINTLSYMBOL = &H15
Private Const LOCALE_SLANGUAGE = &H2
Private Const LOCALE_SLIST = &HC
Private Const LOCALE_SLONGDATE = &H20
Private Const LOCALE_SMONDECIMALSEP = &H16
Private Const LOCALE_SMONGROUPING = &H18
Private Const LOCALE_SMONTHNAME1 = &H38
Private Const LOCALE_SMONTHNAME10 = &H41
Private Const LOCALE_SMONTHNAME11 = &H42
Private Const LOCALE_SMONTHNAME12 = &H43
Private Const LOCALE_SMONTHNAME2 = &H39
Private Const LOCALE_SMONTHNAME3 = &H3A
Private Const LOCALE_SMONTHNAME4 = &H3B
Private Const LOCALE_SMONTHNAME5 = &H3C
Private Const LOCALE_SMONTHNAME6 = &H3D
Private Const LOCALE_SMONTHNAME7 = &H3E
Private Const LOCALE_SMONTHNAME8 = &H3F
Private Const LOCALE_SMONTHNAME9 = &H40
Private Const LOCALE_SMONTHOUSANDSEP = &H17
Private Const LOCALE_SNATIVECTRYNAME = &H8
Private Const LOCALE_SNATIVEDIGITS = &H13
Private Const LOCALE_SNATIVELANGNAME = &H4
Private Const LOCALE_SNEGATIVESIGN = &H51
Private Const LOCALE_SPOSITIVESIGN = &H50
Private Const LOCALE_SSHORTDATE = &H1F
Private Const LOCALE_STHOUSAND = &HF
Private Const LOCALE_STIME = &H1E
Private Const LOCALE_STIMEFORMAT = &H1003

Private Sub GetRegionalSettings() ' Retrieve the regional setting

Dim Symbol As String
Dim iRet1 As Long
Dim iRet2 As Long
Dim lpLCDataVar As String
Dim Pos As Integer
Dim Locale As Long

Locale = GetUserDefaultLCID()

'LOCALE_SDATE is the constant for the date separator
'as stated in declarations
'for any other locale setting just change the constant

'Function can also be re-written to take the
'locale symbol being requested as a parameter

iRet1 = GetLocaleInfo(Locale, LOCALE_SDATE, _
lpLCDataVar, 0)
Symbol = String$(iRet1, 0)

iRet2 = GetLocaleInfo(Locale, LOCALE_SDATE, Symbol, iRet1)
Pos = InStr(Symbol, Chr$(0))
If Pos > 0 Then
Symbol = Left$(Symbol, Pos - 1)
MsgBox "Regional Setting = " + Symbol
End If

End Sub

Private Sub SetRegionalSettings() 'Change the regional setting

Dim Symbol As String
Dim iRet As Long
Dim Locale As Long

'LOCALE_SDATE is the constant for the date separator
'as stated in declarations
'for any other locale setting just change the constant

'Function can also be re-written to take the
'locale information being set as a parameter

Locale = GetUserDefaultLCID() 'Get user Locale ID
Symbol = "-" 'New character for the locale
iRet = SetLocaleInfo(Locale, LOCALE_SDATE, Symbol)

End Sub

numtel
Jan 3rd, 2002, 07:33 AM
are you talkin programmin languages or spoken languages?

shuly
Jan 6th, 2002, 12:45 AM
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

MerrionComputin
Jan 9th, 2002, 05:14 AM
The ApiSystem (http://www.MerrionComputing.com/EventVB/ApiSystem.html) 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

shuly
Jan 10th, 2002, 12:00 AM
My project does not recognize the class EventVb.

Is there any refrence I should give my vb project?

Thanks
Shuly.

MerrionComputin
Jan 10th, 2002, 02:52 AM
The EventVB.dll (http://www.merrioncomputing.com/Download/EventVB.dll) and it's compiled help file (http://www.merrioncomputing.com/Download/EventVB.chm) will be needed.

I'd also recommend you read some of the online help, such as the overview (http://www.merrioncomputing.com/EventVB/Overview.htm) and the help for the ApiLocale (http://www.merrioncomputing.com/EventVB/ApiLocale.html) class.

HTH,
Duncan

shuly
Jan 10th, 2002, 03:25 AM
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.

MerrionComputin
Jan 10th, 2002, 03:33 AM
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 (http://msdn.microsoft.com)

HTH,
Duncan

shuly
Jan 10th, 2002, 03:47 AM
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.

MerrionComputin
Jan 10th, 2002, 08:45 AM
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))

Serge
Jan 10th, 2002, 10:02 AM
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:

Public Declare Sub CopyMemory Lib "KERNEL32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
Public Declare Function GetSystemDefaultLCID Lib "KERNEL32" () As Long
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
Public Declare Function EnumSystemLocales Lib "KERNEL32" Alias "EnumSystemLocalesA" (ByVal lpLocaleEnumProc As Long, ByVal dwFlags As Long) As Long
Public Const LOCALE_SLANGUAGE As Long = &H2
Public Const LOCALE_SABBREVLANGNAME As Long = &H3
Public Const LCID_INSTALLED As Long = &H1
Public Const LCID_SUPPORTED As Long = &H2
Public Const LCID_ALTERNATE_SORTS As Long = &H4


Public Function EnumSystemLocalesProc(p_lngLocaleType As Long) As Long
Dim strLocaleBuffer As String
Dim strLocaleName As String
Dim strLocaleAbbr As String
Dim intPos As Integer
Dim lngLocale As Long


strLocaleBuffer = Space$(32)

CopyMemory ByVal strLocaleBuffer, p_lngLocaleType, ByVal Len(strLocaleBuffer)

intPos = InStr(strLocaleBuffer, vbNullChar)

If intPos Then
strLocaleBuffer = Left$(strLocaleBuffer, intPos - 1)

'last 4 chars are the LocaleID identifier(in Hex)
strLocaleBuffer = (Right$(strLocaleBuffer, 4))

'convert the string to a long
lngLocale = CLng("&H" & strLocaleBuffer)

'get locale info
strLocaleName = GetUserLocaleInfo(lngLocale, LOCALE_SLANGUAGE)
strLocaleAbbr = GetUserLocaleInfo(lngLocale, LOCALE_SABBREVLANGNAME)
End If

Debug.Print strLocaleBuffer & vbTab & lngLocale & vbTab & strLocaleAbbr & vbTab & strLocaleName

'return 1 to continue enumeration
EnumSystemLocalesProc = 1

End Function
Public Function GetUserLocaleInfo(ByVal p_lngLocaleID As Long, ByVal p_lngLocaleType As Long) As String
Dim strBuffer As String
Dim lngRetVal As Long


strBuffer = Space(500)
lngRetVal = GetLocaleInfo(p_lngLocaleID, p_lngLocaleType, strBuffer, Len(strBuffer))

If lngRetVal Then
'lngRetVal holds the size of the string
'including the terminating null
GetUserLocaleInfo = Left$(strBuffer, lngRetVal - 1)
End If
End Function
Private Sub GetAllLocales()
Debug.Print "Installed Locales"
Call EnumSystemLocales ( AddressOf EnumSystemLocalesProc, LCID_INSTALLED)
Debug.Print vbCrLf & "Supported Locales"
Call EnumSystemLocales(AddressOf EnumSystemLocalesProc, LCID_SUPPORTED)
End Sub

Then call the function like:

Call GetAllLocales

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

MerrionComputin
Jan 10th, 2002, 10:08 AM
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.

shuly
Jan 13th, 2002, 12:31 AM
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.