Detecting OS language

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
User avatar
migro
Macro Veteran
Posts: 152
Joined: Thu Nov 06, 2003 5:23 pm
Location: Germany
Contact:

Detecting OS language

Post by migro » Mon Mar 31, 2008 5:58 pm

Hi together!

is there a easy way to detect what language is used from operatingsystem MS is running on?

Any ideas would be great. I like to change the languages used in the script dialogs and messages automatically dependig on the OS-language.
regards
migro

durexlw
Newbie
Posts: 18
Joined: Mon Mar 17, 2008 1:19 pm

Post by durexlw » Tue Apr 01, 2008 1:30 pm

Call the win32 API function: "GetSystemDefaultLangID"

It will return a language identifier:

Code: Select all

LibFunc>Kernel32,GetSystemDefaultLangID,nSysLanguage,
if>nSysLanguage=-64503
	Message>%nSysLanguage% mean the language is American English
endif
You'll find all language identifiers in the Win32 programmers reference if you look for "Language Identifiers and Locales"

0413h is for example "Dutch (Standard)". To know what value Macro scheduler will return you, just do:
0413h = 1043d
65,536 - 1043 = 64493

so when the language is "Dutch (Standard)", macro scheduler will return the value '-64493'. Like this you can extend your script:

Code: Select all

LibFunc>Kernel32,GetSystemDefaultLangID,nSysLanguage,
if>nSysLanguage=-64503
	Message>%nSysLanguage% mean the language is American English
endif
if>nSysLanguage=-64493
	Message>%nSysLanguage% mean the language is Dutch (Standard)
endif
Do this for the rest of the languages you wish to support

User avatar
migro
Macro Veteran
Posts: 152
Joined: Thu Nov 06, 2003 5:23 pm
Location: Germany
Contact:

Post by migro » Tue Apr 01, 2008 3:32 pm

Many thanks durexlw, this haven been a great idea - all works fine.
regards
migro

durexlw
Newbie
Posts: 18
Joined: Mon Mar 17, 2008 1:19 pm

Post by durexlw » Tue Apr 01, 2008 5:50 pm

I appreciate you're letting know this works for you. Glad to hear.

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Tue Apr 01, 2008 5:52 pm

Yeah, that's a good one :)

User avatar
jpuziano
Automation Wizard
Posts: 1085
Joined: Sat Oct 30, 2004 12:00 am

Post by jpuziano » Wed Apr 02, 2008 2:19 am

Hi durexlw,

Thanks for posting this, very useful!
jpuziano

Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post - :-)

rullbandspelare
Pro Scripter
Posts: 149
Joined: Tue Mar 23, 2004 9:11 pm

Re: Detecting OS language

Post by rullbandspelare » Wed Apr 26, 2017 8:50 am

Hi!
I have V14.2.03
And the result is not as expected:

LibFunc>Kernel32,GetSystemDefaultLangID,nSysLanguage,
Gives
0: NSYSLANGUAGE=16385053 <array>

How can I interpret the OS language from this?

rullbandspelare
Pro Scripter
Posts: 149
Joined: Tue Mar 23, 2004 9:11 pm

Re: Detecting OS language

Post by rullbandspelare » Fri May 19, 2017 8:21 am

Here is my findings:

Use this to get the OS language

RegistryReadKey>HKEY_LOCAL_MACHINE,\system\controlset001\control\nls\language,Installlanguage,TheLanguage

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts