Determine active OS langguage
graham samuel
graham.samuel at wanadoo.fr
Wed Oct 5 05:37:22 EDT 2005
Hi Trevor
Tried your function out on a French Windows XP SP2 system running
RunRev 2.6 (after taking out spurious returns) and it didn't work -
it just returned "en" because your registry query put nothing into
tUserLangs. I am no expert, but it looks to me as if the Registry
entries in the French system are under Control Panel\International
\iCountry or \sCountry or \sLanguage
The value of iCountry on my system is 33 [which is the international
phone code] and of sCountry is France [which is of course both French
and English for France - presumably a German system for example would
not say 'Germany' but 'Deutschland', but I haven't got a system to
test it on) and of sLanguage is FRA. There is also \Locale which is a
Hex figure 0000040C.
I'll experiment further it you would like to suggest which direction
to take.
HTH
Graham
On Tue, 4 Oct 2005 16:17:51 -0700, Trevor DeVore
<lists at mangomultimedia.com> wrote:
>
> Here is what I came up with by combing the hints everyone provided.
> My app has language files identified using 2 character language codes
> (en,fr,de,etc). This function returns one of those language codes
> based on the platform the app is running on.
>
> I've tested on OS X with English, French, German, Spanish and
> Italian. I tested Win XP with English and it worked but haven't
> tested the other languages yet since I don't have Windows in anything
> but English. If anyone wants to let me know how it works on their
> international system that would be great. Otherwise I will just wait
> to hear back from the localization company.
>
> Thanks for the pointers.
>
> --
> Trevor DeVore
> Blue Mango Multimedia
> trevor at mangomultimedia.com
>
>
>
>
> /**
> * Returns the two letter language code that our program can use to
> load a language file.
> *
> * @return 2 letter lang
> */
> function getUserLang
> local tAppLangs = "en,fr,de,es,it" --> LANGUAGE CODES THAT
> WILL BE RETURNED BY FUNCTION
> local tAppLangsMac = "en,fr,de,es,it" --> LANGUAGE CODES THAT
> MAC OS RETURNS
> local tAppLangsWin = "9,12,17,10,6" --> DECIMAL
> REPRESENTATIONS OF PRIMARY LANGUAGE CODES WINDOWS RETURNS
> local tUserLangs
> local i
>
> set wholeMatches to true
>
> if platform() is "MacOS" then
> put replaceText(shell("defaults read NSGlobalDomain
> AppleLanguages"),"(\s|\(|\))","") into tUserLangs
>
> repeat for each item tLang in tUserLangs
> put itemOffset(tLang, tAppLangsMac) into i
> if i > 0 then exit repeat
> end repeat
> else if platform() is "Win32" then
> put queryRegistry("HKEY_CURRENT_USER\Control Panel
> \International\Locale") into tUserLangs
> put baseConvert(tUserLangs,16,10) bitAND 1023 into tUserLangs
>
> repeat for each item tLang in tUserLangs
> put itemOffset(tLang, tAppLangsWin) into i
> if i > 0 then exit repeat
> end repeat
>
> --> LINUX
> else
>
> end if
>
> if i > 0 then return item i of tAppLangs
> else return "en"
> end getUserLang
----------------------------------------
Graham Samuel / The Living Fossil Co. / UK and France
More information about the use-livecode
mailing list