Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

List of locales in Windows

On *nix systems you can do locale -a to get a list of available locales.

What is the equivalent command (or action) in Windows?

I've seen lists on the Internet, but most of them are of just locale labels and not actual locale names. Plus, not all systems are guaranteed to have all of them installed, right?

Note that my definition of "locale" here is "locale string", i.e. a second parameter to C's setlocale() which will result in a non-NULL return value.

Programmatic answers are also fine, I'm just tired of brute force guessing Windows locale names.

like image 205
aib Avatar asked Mar 01 '11 09:03

aib


People also ask

How many locales are there?

Edit: The original list of locales has been edited to add additional locales that were not included before. Now 228 listed. The most important thing for various versions of English is in formatting numbers and dates. Other differences are significant to the extent that you want and able to cater to specific variations.

What is my computer locale?

System LocaleSelect Start > Control Panel > Clock, Language, and Region > Region and Language.

What is locale name?

A locale name is based on the language tagging conventions of IETF BCP 47 ( Windows Vista and later), and is represented by LOCALE_SNAME. Generally, the pattern <language>-<REGION> is used. Here, language is a lowercase ISO 639 language code. The codes from ISO 639-1 are used when available.


1 Answers

Initially, I couldn't find a C/Win32 API to get the information. (See later edit.) However, it looks like the .NET class System.Globalization.CultureInfo could provide the information you need. In particular, see CultureInfo.GetCultures(). This page seems to have a complete example of what you are looking for.

EDIT: If you prefer a C/Win32 API, see EnumSystemLocales() function.

EDIT 2: This example shows how to convert an LCID (which you get from EnumSystemLocales()) into a string useable by setlocale().

like image 168
Eric Pi Avatar answered Nov 08 '22 11:11

Eric Pi