How can I get system locale in Windows 7?
I mean something like: cs_CZ.UTF-8
I tried writing "locale" in the command line but that doesn't work in Windows. Any suggestions?
How can I get system locale in Windows 7?
I mean something like: cs_CZ.UTF-8
I tried writing "locale" in the command line but that doesn't work in Windows. Any suggestions?
There's not a specific command (or at least, not one that I'm aware of) to get this information, but you can find it between those provided by
systeminfo.exe
.Get-UICulture
orGet-Host
in PowerShell(capitalization optional)
If you need the actual locale to conditionally do other things in a batch file you can create a batch file (save a text file as .bat extension) with the following. As a starting point this will print to the command prompt, for example, "en-us" (no quotes) You can also use the variable !VERBOSE_SYSTEM_LOCALE! for the human readable locale e.g. English(UnitedStates)
In fact, your proposals fail, because they rely on searching a string ("System Locale") which changes depending on the current locale! On my french Win10Pro, the string is "Option régionale du système" (with accented letter, which is very difficult to handle properly in a CMD file).
I've done some testing, and it seems, on MY system, that the lines about locale in systeminfo output are the only ones to contain a semi-colon character (";"):
Based on that (which may NOT be true on other systems with different languages), I coded this get_locale.cmd script :
The result of my script on MY system is:
Be warned, however, that the three environment variables exist only inside the script, they do NOT persist in CMD environment after the script ends (no export command as in *nix).
me again.
I discovered a slight enhancement to my script. Using SETX one can store environment variables into USER environment for future CMD Windows to use (as stated in SETX /? second remark).
Then the get_locale.cmd script becomes:
For the VERBOSE_SYSTEM_LOCALE variable, since the value is possibly several words long, it is required to wrap %%C into quotes so that SETX receives only one parameter as expected.
Now, in any new CMD window, these values will be available:
PS: It would be nice if other contributors from other countries with other languages could confirm that looking for semi-colon ';' works on their Windows systems. Thanks in advance!