How does one determine the language used on a windows OS?

S

stylechief

A program needs to determine whether to use the metric system or
American units before the GUI is displayed with units of measure. I am
thinking that checking the language used on a system might be the way
to do this. I know that on UNIX/Linux/AIX systems there is a LANG
environment variable that would make this easy, e.g. LANG=en_US. But
Windows systems lack this variable.
How does one determine the language on a Windows box, and is there
perhaps a better method to accomplish determining what country the
machine is in?
Thanks for your time.
Liam
 
A

A. Sinan Unur

A program needs to determine whether to use the metric system or
American units before the GUI is displayed with units of measure. I
am thinking that checking the language used on a system might be the
way to do this. I know that on UNIX/Linux/AIX systems there is a LANG
environment variable that would make this easy, e.g. LANG=en_US.

You need a platform specific way to access locale data.
But Windows systems lack this variable.
So?

How does one determine the language on a Windows box, and is there
perhaps a better method to accomplish determining what country the
machine is in?

The possible answers to your question are independent of the programming
language used.

You might want post your question on a Windows programming group, or
read Microsoft's API documentation.

Sinan
 
E

Eden Cardim

stylechief said:
A program needs to determine whether to use the metric system or
American units before the GUI is displayed with units of measure. I am
thinking that checking the language used on a system might be the way
to do this. I know that on UNIX/Linux/AIX systems there is a LANG
environment variable that would make this easy, e.g. LANG=en_US. But
Windows systems lack this variable.
How does one determine the language on a Windows box, and is there
perhaps a better method to accomplish determining what country the
machine is in?

You can get that info in the registry, I don't know exactly where it is
cos' I don't have a windows box available right now. It's somewhere
around HKEY_LOCAL_MACHINE\Software\Microsoft\Windows, or something like
that. Once you find out the key where it's stored you can use
Win32API::Registry module to get at the info.
 
B

Brian Wakem

stylechief said:
A program needs to determine whether to use the metric system or
American units before the GUI is displayed with units of measure. I am
thinking that checking the language used on a system might be the way
to do this. I know that on UNIX/Linux/AIX systems there is a LANG
environment variable that would make this easy, e.g. LANG=en_US. But
Windows systems lack this variable.
How does one determine the language on a Windows box, and is there
perhaps a better method to accomplish determining what country the
machine is in?
Thanks for your time.
Liam


Why not ask the user what he/she wants, or have the option to change at the
flick of a switch.

Many Windows PCs sold in the UK are pre-installed as per US spec, so don't
rely on getting accurate data from the registry.
 
D

Dr.Ruud

Eden Cardim:
stylechief:

You can get that info in the registry, I don't know exactly where it
is cos' I don't have a windows box available right now. It's somewhere
around HKEY_LOCAL_MACHINE\Software\Microsoft\Windows, or something
like that. Once you find out the key where it's stored you can use
Win32API::Registry module to get at the info.

No need to go so low.
 
S

stylechief

Excellent suggestion. I will use the Locale.pm module mentioned above,
but also include a drop-down menu feature that will allow one to switch.
 
D

Dr.Ruud

A. Sinan Unur schreef:
stylechief:

The possible answers to your question are independent of the
programming language used.

You might want post your question on a Windows programming group, or
read Microsoft's API documentation.

Or look for a platform-independent way.

POSIX maybe?

$ perl -MPOSIX -e '$lconv=POSIX::localeconv(); print
$lconv->{decimal_point}, "\n"';
 
D

Dr.Ruud

Dr.Ruud schreef:
A. Sinan Unur:

Or look for a platform-independent way.

POSIX maybe?

$ perl -MPOSIX -e '$lconv=POSIX::localeconv(); print
$lconv->{decimal_point}, "\n"';

On Windows:
$ perl -MPOSIX -e "$lconv=POSIX::localeconv(); print
$lconv->{decimal_point}, \"\n\"";
;)
 
S

stylechief

I found also that there is a registry value (platform specific,
however): "iMeasure" located in HKCU\Control Panel\International.
0=Metric, 1=U.S.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top