Jump to content
Sign in to follow this  
BinaryBrother

LCID to Language code

Recommended Posts

BinaryBrother

I've looked and looked, and can't seem to find anything...

I figured out how to get the LangID of the system my program is ran on from kernel32.dll by doing this...

$DLL = DllOpen("kernel32.dll")
$LangID=DllCall ($DLL, "int", "GetUserDefaultLangID")

OutPut RAW: 1033

Output Hex: 0409

But finding a way to convert that to "en_US" seems to be a challenge... :D

Any help is appreciated. :huggles:

Edited by BinaryBrother

Share this post


Link to post
Share on other sites
jchd

But finding a way to convert that to "en_US" seems to be a challenge... :D

Can this help? It can enumerate via callback available combinations.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites
BinaryBrother

This function enumerates the locales that are either installed on or supported by a system.

I'm already acquiring the LangID... Now I need a way to convert it to the name... Ex. "en-us"

Share this post


Link to post
Share on other sites
jchd

I'm already acquiring the LangID... Now I need a way to convert it to the name... Ex. "en-us"

I don't know MSDN by heart, by I found the above function more or less related. Once you can enumerate the names, can't you convert them to their numeric ID? I'm sure I already saw that before on MSDN but I fail to find it now...

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites
jchd

This call seem to be what you need, but is only available > Vista: msdn again


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites
jchd

Gah, I'm lost trying to use DLL pointers... :D

Does this work? Can't test it on Vista or 7 right now here.

Local $DLL = "kernel32.dll", $ret, $LangID, $name
$ret = DllCall ($DLL, "int", "GetUserDefaultLangID")
;~ If @error ...
$LangID = $ret[0]
$ret = DllCall($DLL, "int", "GetUserDefaultLocaleName", "wstr", "", "int", 85)
;~ If @error ...
$name = $ret[1]
ConsoleWrite($LangID & ' = ' & $name & @LF)

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites
BinaryBrother

Win7 X64 and Server 2008 R2 tested... Works great, man... I was trying some really overly complex stuff... Thanks, thanks a lot! :D

Share this post


Link to post
Share on other sites
jchd

Win7 X64 and Server 2008 R2 tested... Works great, man... I was trying some really overly complex stuff... Thanks, thanks a lot! :D

Don't forget the If @error on the getname call, since it _will_ fail on XP...

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites
BinaryBrother

This is a specialized program that will be running on Win7 only. :huggles:

But thanks for the error handling advise. God knows I need to do more of it...:D

Share this post


Link to post
Share on other sites
ProgAndy

I have a working example for WinXP :D For Windows below WinVista, you have to install the Microsoft National Language Support Downlevel APIs 1.0

Global $LocaleName=''
Select
    Case @OSBuild >= 6000
        Local $tBuffer = DllStructCreate("wchar[85]")
        ;DllCall("kernel32.dll", 'int', "GetSystemDefaultLocaleName", 'ptr', DllStructGetPtr($tBuffer), 'int', 85)
        DllCall("kernel32.dll", 'int', "GetUserDefaultLocaleName", 'ptr', DllStructGetPtr($tBuffer), 'int', 85)
        $LocaleName = DllStructGetData($tBuffer,1)
    Case Else
        Local $tBuffer = DllStructCreate("wchar[85]")
        ;Local $iLCID = DllCall("kernel32.dll", "dword", "GetSystemDefaultLCID")
        Local $iLCID = DllCall("kernel32.dll", "dword", "GetUserDefaultLCID")
        If Not @error Then $iLCID = $iLCID[0]
        DllCall('nlsdl.dll', 'int', 'DownlevelLCIDToLocaleName', 'dword', $iLCID, 'ptr', DllStructGetPtr($tBuffer), 'int', 85, 'int', 0) ; LOCALE_SYSTEM_DEFAULT = 0x0800
        $LocaleName = DllStructGetData($tBuffer,1)
EndSelect
        
MsgBox(0, '', $LocaleName)
Edited by ProgAndy

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Share this post


Link to post
Share on other sites
jchd

I have a working example for WinXP :D For Windows below WinVista, you have to install the Microsoft National Language Support Downlevel APIs 1.0

That's what MSDN says, but I suspect that only very few XP machines have this installed since this kind of optional component it isn't part of any service pack nor standard updates AFAIK. That's why I didn't bother to mention it.

BTW, to ease your life you don't have to use a the dllstruct for output Unicode variables. Just pass an empty string: DllCall does the work for you anyway. It contributes to save some cycles.

Global $LocaleName
Local $ret
If @OSBuild >= 6000 Then
    $ret = DllCall("kernel32.dll", 'int', "GetUserDefaultLocaleName", 'ptr', '', 'int', 85)
    $LocaleName = $ret[1]
Else
    $ret = DllCall("kernel32.dll", "dword", "GetUserDefaultLCID")
    If Not @error Then
    $ret = DllCall('nlsdl.dll', 'int', 'DownlevelLCIDToLocaleName', 'dword', $ret[0], 'ptr', '', 'int', 85, 'int', 0) ; LOCALE_SYSTEM_DEFAULT = 0x0800
    If Not @error Then $LocaleName = $ret[1]
    Endif
EndIf
MsgBox(0, '', $LocaleName)

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites
KaFu

Or use this table to create a reference array.

; Example 1
MsgBox(64,"Language ID - _GetLCID from @OSLang",@OSLang & @crlf & _GetLCID("0x" & @OSLang))

; Example 2
$DLL = DllOpen("kernel32.dll")
$LangID=DllCall ($DLL, "int", "GetUserDefaultLangID")
MsgBox(64,"Language ID - _GetLCID from GetUserDefaultLangID",hex($LangID[0],4) & @crlf & _GetLCID("0x" & hex($LangID[0],4)))


Func _GetLCID($iHex)
    Local $aArray = StringRegExp(_Locale_ID_LCID_Chart(), ";" & $iHex & "\|(.*?);", 3)
    If @error Then
        Return ""
    EndIf
    Return $aArray[0]
EndFunc   ;==>_GetLCID


Func _Locale_ID_LCID_Chart()
    ; http://msdn.microsoft.com/en-us/library/0h88fahh%28VS.85%29.aspx
    Local $sString = ";0x0436|1078,Afrikaans,af" & _
            ";0x041C|1052,Albanian,sq" & _
            ";0x3801|14337,Arabic - United Arab Emirates,ar-ae" & _
            ";0x3C01|15361,Arabic - Bahrain,ar-bh" & _
            ";0x1401|5121,Arabic - Algeria,ar-dz" & _
            ";0x0C01|3073,Arabic - Egypt,ar-eg" & _
            ";0x0801|2049,Arabic - Iraq,ar-iq" & _
            ";0x2C01|11265,Arabic - Jordan,ar-jo" & _
            ";0x3401|13313,Arabic - Kuwait,ar-kw" & _
            ";0x3001|12289,Arabic - Lebanon,ar-lb"
    $sString &= ";0x1001|4097,Arabic - Libya,ar-ly" & _
            ";0x1801|6145,Arabic - Morocco,ar-ma" & _
            ";0x2001|8193,Arabic - Oman,ar-om" & _
            ";0x4001|16385,Arabic - Qatar,ar-qa" & _
            ";0x0401|1025,Arabic - Saudi Arabia,ar-sa" & _
            ";0x2801|10241,Arabic - Syria,ar-sy" & _
            ";0x1C01|7169,Arabic - Tunisia,ar-tn" & _
            ";0x2401|9217,Arabic - Yemen,ar-ye" & _
            ";0x042B|1067,Armenian,hy" & _
            ";0x042C|1068,Azeri - Latin,az-az"
    $sString &= ";0x082C|2092,Azeri - Cyrillic,az-az" & _
            ";0x042D|1069,Basque,eu" & _
            ";0x0423|1059,Belarusian,be" & _
            ";0x0402|1026,Bulgarian,bg" & _
            ";0x0403|1027,Catalan,ca" & _
            ";0x0804|2052,Chinese - China,zh-cn" & _
            ";0x0C04|3076,Chinese - Hong Kong SAR,zh-hk" & _
            ";0x1404|5124,Chinese - Macau SAR,zh-mo" & _
            ";0x1004|4100,Chinese - Singapore,zh-sg" & _
            ";0x0404|1028,Chinese - Taiwan,zh-tw"
    $sString &= ";0x041A|1050,Croatian,hr" & _
            ";0x0405|1029,Czech,cs" & _
            ";0x0406|1030,Danish,da" & _
            ";0x0413|1043,Dutch - Netherlands,nl-nl" & _
            ";0x0813|2067,Dutch - Belgium,nl-be" & _
            ";0x0C09|3081,English - Australia,en-au" & _
            ";0x2809|10249,English - Belize,en-bz" & _
            ";0x1009|4105,English - Canada,en-ca" & _
            ";0x2409|9225,English - Caribbean,en-cb" & _
            ";0x1809|6153,English - Ireland,en-ie"
    $sString &= ";0x2009|8201,English - Jamaica,en-jm" & _
            ";0x1409|5129,English - New Zealand,en-nz" & _
            ";0x3409|13321,English - Phillippines,en-ph" & _
            ";0x1C09|7177,English - Southern Africa,en-za" & _
            ";0x2C09|11273,English - Trinidad,en-tt" & _
            ";0x0809|2057,English - Great Britain,en-gb" & _
            ";0x0409|1033,English - United States,en-us" & _
            ";0x0425|1061,Estonian,et" & _
            ";0x0429|1065,Farsi,fa" & _
            ";0x040B|1035,Finnish,fi"
    $sString &= ";0x0438|1080,Faroese,fo" & _
            ";0x040C|1036,French - France,fr-fr" & _
            ";0x080C|2060,French - Belgium,fr-be" & _
            ";0x0C0C|3084,French - Canada,fr-ca" & _
            ";0x140C|5132,French - Luxembourg,fr-lu" & _
            ";0x100C|4108,French - Switzerland,fr-ch" & _
            ";0x083C|2108,Gaelic - Ireland,gd-ie" & _
            ";0x043C|1084,Gaelic - Scotland,gd" & _
            ";0x0407|1031,German - Germany,de-de" & _
            ";0x0C07|3079,German - Austria,de-at"
    $sString &= ";0x1407|5127,German - Liechtenstein,de-li" & _
            ";0x1007|4103,German - Luxembourg,de-lu" & _
            ";0x0807|2055,German - Switzerland,de-ch" & _
            ";0x0408|1032,Greek,el" & _
            ";0x040D|1037,Hebrew,he" & _
            ";0x0439|1081,Hindi,hi" & _
            ";0x040E|1038,Hungarian,hu" & _
            ";0x040F|1039,Icelandic,is" & _
            ";0x0421|1057,Indonesian,id" & _
            ";0x0410|1040,Italian - Italy,it-it"
    $sString &= ";0x0810|2064,Italian - Switzerland,it-ch" & _
            ";0x0411|1041,Japanese,ja" & _
            ";0x0412|1042,Korean,ko" & _
            ";0x0426|1062,Latvian,lv" & _
            ";0x0427|1063,Lithuanian,lt" & _
            ";0x042F|1071,F.Y.R.O. Macedonia,mk" & _
            ";0x043E|1086,Malay - Malaysia,ms-my" & _
            ";0x083E|2110,Malay – Brunei,ms-bn" & _
            ";0x043A|1082,Maltese,mt" & _
            ";0x044E|1102,Marathi,mr"
    $sString &= ";0x0414|1044,Norwegian - Bokml,no-no" & _
            ";0x0814|2068,Norwegian - Nynorsk,no-no" & _
            ";0x0415|1045,Polish,pl" & _
            ";0x0816|2070,Portuguese - Portugal,pt-pt" & _
            ";0x0416|1046,Portuguese - Brazil,pt-br" & _
            ";0x0417|1047,Raeto-Romance,rm" & _
            ";0x0418|1048,Romanian - Romania,ro" & _
            ";0x0818|2072,Romanian - Republic of Moldova,ro-mo" & _
            ";0x0419|1049,Russian,ru" & _
            ";0x0819|2073,Russian - Republic of Moldova,ru-mo"
    $sString &= ";0x044F|1103,Sanskrit,sa" & _
            ";0x0C1A|3098,Serbian - Cyrillic,sr-sp" & _
            ";0x081A|2074,Serbian - Latin,sr-sp" & _
            ";0x0432|1074,Setsuana,tn" & _
            ";0x0424|1060,Slovenian,sl" & _
            ";0x041B|1051,Slovak,sk" & _
            ";0x042E|1070,Sorbian,sb" & _
            ";0x040A|1034,Spanish - Spain (Traditional),es-es" & _
            ";0x2C0A|11274,Spanish - Argentina,es-ar" & _
            ";0x400A|16394,Spanish - Bolivia,es-bo"
    $sString &= ";0x340A|13322,Spanish - Chile,es-cl" & _
            ";0x240A|9226,Spanish - Colombia,es-co" & _
            ";0x140A|5130,Spanish - Costa Rica,es-cr" & _
            ";0x1C0A|7178,Spanish - Dominican Republic,es-do" & _
            ";0x300A|12298,Spanish - Ecuador,es-ec" & _
            ";0x100A|4106,Spanish - Guatemala,es-gt" & _
            ";0x480A|18442,Spanish - Honduras,es-hn" & _
            ";0x080A|2058,Spanish - Mexico,es-mx" & _
            ";0x4C0A|19466,Spanish - Nicaragua,es-ni" & _
            ";0x180A|6154,Spanish - Panama,es-pa"
    $sString &= ";0x280A|10250,Spanish - Peru,es-pe" & _
            ";0x500A|20490,Spanish - Puerto Rico,es-pr" & _
            ";0x3C0A|15370,Spanish - Paraguay,es-py" & _
            ";0x440A|17418,Spanish - El Salvador,es-sv" & _
            ";0x380A|14346,Spanish - Uruguay,es-uy" & _
            ";0x200A|8202,Spanish - Venezuela,es-ve" & _
            ";0x0430|1072,Southern Sotho,st" & _
            ";0x0441|1089,Swahili,sw" & _
            ";0x041D|1053,Swedish - Sweden,sv-se" & _
            ";0x081D|2077,Swedish - Finland,sv-fi"
    $sString &= ";0x0449|1097,Tamil,ta" & _
            ";0X0444|1092,Tatar,tt" & _
            ";0x041E|1054,Thai,th" & _
            ";0x041F|1055,Turkish,tr" & _
            ";0x0431|1073,Tsonga,ts" & _
            ";0x0422|1058,Ukrainian,uk" & _
            ";0x0420|1056,Urdu,ur" & _
            ";0x0843|2115,Uzbek - Cyrillic,uz-uz" & _
            ";0x0443|1091,Uzbek – Latin,uz-uz" & _
            ";0x042A|1066,Vietnamese,vi"
    $sString &= ";0x0434|1076,Xhosa,xh" & _
            ";0x043D|1085,Yiddish,yi" & _
            ";0x0435|1077,Zulu,zu"

    Return $sString

EndFunc   ;==>_Locale_ID_LCID_Chart
Edited by KaFu

Share this post


Link to post
Share on other sites
Jos

There is a func in Autoit3Wrapper & GUI to get you started:

Edited it to make it more generic.

$iCountry_Desc = ""
$ICountry_Code = 2057
Language_Code($ICountry_Code,$iCountry_Desc,1)
ConsoleWrite('$iCountry_Desc = ' & $iCountry_Desc &  ' >Error code: ' & @error & @crlf)
;
$iCountry_Desc = ""
$ICountry_Code = 99999999
Language_Code($ICountry_Code,$iCountry_Desc,1)
ConsoleWrite('$iCountry_Desc = ' & $iCountry_Desc &  ' >Error code: ' & @error & @crlf)
;
$iCountry_Desc = ""
$ICountry_Code = ""
Language_Code($ICountry_Code,$iCountry_Desc,1)
ConsoleWrite('$iCountry_Desc = ' & $iCountry_Desc &  ' >Error code: ' & @error & @crlf)

; Reverse lookup
$iCountry_Desc = "Dutch"
$ICountry_Code = ""
Language_Code($ICountry_Code,$iCountry_Desc,2)
ConsoleWrite('$ICountry_Code = ' & $ICountry_Code &  ' >Error code: ' & @error & @crlf)
;
$iCountry_Desc = "Doesn't exists"
$ICountry_Code = ""
Language_Code($ICountry_Code,$iCountry_Desc,2)
ConsoleWrite('$ICountry_Code = ' & $ICountry_Code &  ' >Error code: ' & @error & @crlf)
;
$iCountry_Desc = ""
$ICountry_Code = ""
Language_Code($ICountry_Code,$iCountry_Desc,2)
ConsoleWrite('$ICountry_Code = ' & $ICountry_Code &  ' >Error code: ' & @error & @crlf)



Func Language_Code(ByRef $code, ByRef $Country, $task = 1)
    Local $CountryArray[120][2] = [["Afrikaans", "1078"],["Albanian", "1052"],["Arabic (Algeria)", "5121"],["Arabic (Bahrain)", "15361"], _
            ["Arabic (Egypt)", "3073"],["Arabic (Iraq)", "2049"],["Arabic (Jordan)", "11265"],["Arabic (Kuwait)", "13313"],["Arabic (Lebanon)", "12289"], _
            ["Arabic (Libya)", "4097"],["Arabic (Morocco)", "6145"],["Arabic (Oman)", "8193"],["Arabic (Qatar)", "16385"],["Arabic (Saudi Arabia)", "1025"], _
            ["Arabic (Syria)", "10241"],["Arabic (Tunisia)", "7169"],["Arabic (U.A.E.)", "14337"],["Arabic (Yemen)", "9217"],["Basque", "1069"], _
            ["Belarusian", "1059"],["Bulgarian", "1026"],["Catalan", "1027"],["Chinese (Hong Kong SAR)", "3076"],["Chinese (PRC)", "2052"], _
            ["Chinese (Singapore)", "4100"],["Chinese (Taiwan)", "1028"],["Croatian", "1050"],["Czech", "1029"],["Danish", "1030"], _
            ["Dutch", "1043"],["Dutch (Belgium)", "2067"],["English (Australia)", "3081"],["English (Belize)", "10249"],["English (Canada)", "4105"], _
            ["English (Ireland)", "6153"],["English (Jamaica)", "8201"],["English (New Zealand)", "5129"],["English (South Africa)", "7177"], _
            ["English (Trinidad)", "11273"],["English (United Kingdom)", "2057"],["English (United States)", "1033"],["Estonian", "1061"], _
            ["Faeroese", "1080"],["Farsi", "1065"],["Finnish", "1035"],["French (Standard)", "1036"],["French (Belgium)", "2060"], _
            ["French (Canada)", "3084"],["French (Luxembourg)", "5132"],["French (Switzerland)", "4108"],["Gaelic (Scotland)", "1084"], _
            ["German (Standard)", "1031"],["German (Austrian)", "3079"],["German (Liechtenstein)", "5127"],["German (Luxembourg)", "4103"], _
            ["German (Switzerland)", "2055"],["Greek", "1032"],["Hebrew", "1037"],["Hindi", "1081"],["Hungarian", "1038"],["Icelandic", "1039"], _
            ["Indonesian", "1057"],["Italian (Standard)", "1040"],["Italian (Switzerland)", "2064"],["Japanese", "1041"],["Korean", "1042"], _
            ["Latvian", "1062"],["Lithuanian", "1063"],["Macedonian (FYROM)", "1071"],["Malay (Malaysia)", "1086"],["Maltese", "1082"], _
            ["Norwegian (Bokmål)", "1044"],["Polish", "1045"],["Portuguese (Brazil)", "1046"],["Portuguese (Portugal)", "2070"], _
            ["Raeto (Romance)", "1047"],["Romanian", "1048"],["Romanian (Moldova)", "2072"],["Russian", "1049"],["Russian (Moldova)", "2073"], _
            ["Serbian (Cyrillic)", "3098"],["Setsuana", "1074"],["Slovak", "1051"],["Slovenian", "1060"],["Sorbian", "1070"], _
            ["Spanish (Argentina)", "11274"],["Spanish (Bolivia)", "16394"],["Spanish (Chile)", "13322"],["Spanish (Columbia)", "9226"], _
            ["Spanish (Costa Rica)", "5130"],["Spanish (Dominican Republic)", "7178"],["Spanish (Ecuador)", "12298"],["Spanish (El Salvador)", "17418"], _
            ["Spanish (Guatemala)", "4106"],["Spanish (Honduras)", "18442"],["Spanish (Mexico)", "2058"],["Spanish (Nicaragua)", "19466"], _
            ["Spanish (Panama)", "6154"],["Spanish (Paraguay)", "15370"],["Spanish (Peru)", "10250"],["Spanish (Puerto Rico)", "20490"], _
            ["Spanish (Spain)", "1034"],["Spanish (Uruguay)", "14346"],["Spanish (Venezuela)", "8202"],["Sutu", "1072"], _
            ["Swedish", "1053"],["Swedish (Finland)", "2077"],["Thai", "1054"],["Turkish", "1055"],["Tsonga", "1073"], _
            ["Ukranian", "1058"],["Urdu (Pakistan)", "1056"],["Vietnamese", "1066"],["Xhosa", "1076"],["Yiddish", "1085"],["Zulu", "1077"]]
    $CountryTable = ""
    If $task = 1 And $code = 0 Then SetError(1)
    If $task = 2 And $Country = "" Then SetError(2)
    For $x = 0 To UBound($CountryArray) - 1
        Switch $task
            Case 1
                $CountryTable &= $CountryArray[$x][0] & "|"
                If $CountryArray[$x][1] = $code Then
                    $Country = $CountryArray[$x][0]
                    ExitLoop
                EndIf
            Case 2
                If $CountryArray[$x][0] = $Country Then
                    $code = $CountryArray[$x][1]
                    ExitLoop
                EndIf
        EndSwitch
    Next
    If $task = 1 And $Country = "" Then SetError(3)
    If $task = 2 And $code = 0 Then SetError(4)
EndFunc   ;==>Language_Code
Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
jchd

There are indeed a plethora of solutions. But relying on a fixed table can lead (rarely I confess) to mistakes since I read that Vista and up allow for custom locales, even really weird ones.

But of course only very few systems are setup this way.


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites
ProgAndy

There are indeed a plethora of solutions. But relying on a fixed table can lead (rarely I confess) to mistakes since I read that Vista and up allow for custom locales, even really weird ones.

But of course only very few systems are setup this way.

The alternative solutions are mainly for older OS where custom locales are not allowed and no native API exists to get the names from the IDs :D

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×