Determine active OS langguage

graham samuel graham.samuel at wanadoo.fr
Thu Oct 6 03:30:05 EDT 2005


Hi Trevor

I just tried your test (directly from your Rev user area) on my  
French XP machine and it still returned 'en'. I then had a look at it  
and found that the line

  replaceText(shell("defaults...

resulted in a long text in French being put into tUserLangs. This  
reads (including the single quote):

'defaults'n'estpasreconnuentantquecommandeinterneouexterne,unprogrammeex 
écutableouunfichierdecommandes.

I don't know what happened to the spaces in this message, but as you  
can see it doesn't like the word 'defaults'.

More significantly the 'queryregistry' call doesn't happen in your  
script because it would only be called if the platform **wasn't**  
Win32, which it is! I altered the logic a bit so that the registery  
is queried  for the Win32 case, and bingo! I got 'fr'. So the key  
idea works. Don't know what the replaceText problem is.

HTH

Graham


On Wed, 5 Oct 2005 10:07:36 -0700, Trevor DeVore  
<lists at mangomultimedia.com> wrote:
>
> Thanks for a taking a look at this Graham.  Let me walk through the
> logic of the function to see where it might be going wrong.
>
> Right now the function queries the "HKEY_CURRENT_USER\Control Panel
> \International\Locale" which returns the hex value you noted above.
> This hex value is a combination of a primary and sublanguage
> identifier which you can find information about here:
>
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/intl/
> nls_238z.asp
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/intl/
> nls_61df.asp
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/intl/
> nls_19ir.asp
>
> What my code is supposed to do is extract the primary language
> identifier from the registry value which I can compare against the
> documented values that Microsoft provides.
>
> So for French (Standard) we start with the hex value 0x040c (what
> your system has).  In order to extract the primary language
> identifier from the language identifer (0x040c) we need to do a
> bitAND operation.  Somewhere deep in the microsoft site it tells you
> that that value to use for this operation is 0x3FF (or 1023) in
> decimal form but I can't find the reference right now.  Revolution
> requires the decimal form when using bitAND so we end up with this:
>
> get queryRegistry("HKEY_CURRENT_USER\Control Panel\International
> \Locale") --> RETURNS HEX
> get baseConvert(it,16,10) --> CONVERT HEX TO DECIMAL (1036 FOR FRENCH
> STANDARD)
> get it bitAND 1023
>
> Using the value you gave for your system (0x040c) the value of it in
> the above transcript ends up being 12 which is what I would expect it
> to be for French.  I wonder if maybe there was a problem when you
> copied and pasted the script.  I uploaded a stack to my user space on
> RevOnline.  Look for getUserLang under "trevordevore".  There is just
> one button to click and it will display the language your os is
> running (for english, french, german, spanish and italian).  Could
> you let me know if that works on your system?  The version of the
> function is slightly updated in the stack so if it does work there
> could have been a problem in my original function.
>

----------------------------------------
Graham Samuel / The Living Fossil Co. / UK and France




More information about the use-livecode mailing list