Locale Names
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. Otherwise, codes from ISO 639-2/T are used. REGION specifies an uppercase ISO 3166-1 country/region identifier. For example, the locale name for English (United States) is "en-US" and the locale name for Divehi (Maldives) is "dv-MV".
Note
The constant LOCALE_NAME_MAX_LENGTH gives the maximum length of a locale name. It includes space for a terminating null character.
If the locale is a neutral locale (no region), the LOCALE_SNAME value follows the pattern <language>
. If it is a neutral locale for which the script is significant, the pattern is <language>-<Script>
.
If a locale must be distinguished from another locale for the same language and region using a different script, the LOCALE_SNAME value follows the pattern <language>-<Script>-<REGION>
, where Script is an initial-uppercase ISO 15924 script code. For example, the LOCALE_SNAME value for the specific locale Uzbek (Latin, Uzbekistan) is "uz-Latn-UZ". The script component is not included in cases where a language is commonly written in only one script.
Sort orders for locales are designated using sort order identifiers, for example, SORT_DEFAULT. To distinguish two or more sort orders for the same language and region, the locale name follows the pattern <language>-<REGION>\_<sort order>
. If you must distinguish both script and sort order, the name follows the pattern <language>-<Script>-<REGION>\_<sort order>
. The default sort order is never explicitly specified, only the alternative sort order. For example, Hungarian (Hungary) with either SORT_DEFAULT or the numerically equivalent SORT_HUNGARIAN_DEFAULT is designated "hu-HU". Hungarian (Hungary) with sort order SORT_HUNGARIAN_TECHNICAL is designated "hu-HU_technl".
For a replacement locale, the locale name must be the same as the name for the locale being replaced. For a supplemental locale, the locale name should follow the pattern of <language>-<REGION>-x-<custom>
or <language>-<Script>-<REGION>-x-<custom>
, where <custom>
is an alphanumeric string specific to the supplemental locale. For example, a supplemental locale specific to a company called Fabricam might be called "en-US-x-fabricam".
An application can retrieve the current locale names by using the GetSystemDefaultLocaleName and GetUserDefaultLocaleName functions. While each thread can retrieve and set its own locale identifier with GetThreadLocale and set it with SetThreadLocale, there are no analogous functions to get and set locale by name.