Locale (computer software)

Short description: Parameters defining locale in computer

In computing, a locale is a set of parameters that defines the user's language, region and any special variant preferences that the user wants to see in their user interface. Usually a locale identifier consists of at least a language code and a country/region code. Locale is an important aspect of i18n.

## Contents

* 1 General locale settings
* 2 Programming and markup language support
* 3 International standards
* 3.1 POSIX platforms
* 4 Specifics for Microsoft platforms
* 5 See also
* 6 References
* 7 External links

## General locale settings

These settings usually include the following display (output) format settings:

* Number format setting (LC_NUMERIC, C/C++)
* Character classification, case conversion settings (LC_CTYPE, C/C++)
* Date-time format setting (LC_TIME, C/C++)
* String collation setting (LC_COLLATE, C/C++)
* Currency format setting (LC_MONETARY, C/C++)
* Paper size setting (LC_PAPER, ISO 30112)
* Color setting

The locale settings are about formatting output given a locale. So, the time zone information and daylight saving time are not usually part of the locale settings. Less usual is the input format setting, which is mostly defined on a per application basis.

## Programming and markup language support

In these environments,

* C
* C++
* Eiffel
* Java
* .NET Framework
* REBOL
* Ruby
* Perl
* PHP
* Python
* XML
* JSP
* JavaScript

and other (nowadays) Unicode-based environments, they are defined in a format similar to BCP 47. They are usually defined with just ISO 639 (language) and ISO 3166-1 alpha-2 (2-letter country) codes.

## International standards

In standard C and C++, locale is defined in "categories" of LC_COLLATE (text collation), LC_CTYPE (character class), LC_MONETARY (currency format), LC_NUMERIC (number format), and LC_TIME (time format). The special LC_ALL category can be used to set all locale settings.[1]

There is no standard locale names associated with C and C++ standards besides a "minimal locale" name "C", although the POSIX format is a commonly-used baseline.

### POSIX platforms

On POSIX platforms such as Unix, Linux and others, locale identifiers are defined in a way similar to the BCP 47 definition of language tags, but the locale variant modifier is defined differently, and the character set is optionally included as a part of the identifier. The POSIX or "XPG" format is [language[_territory][.codeset][@modifier]]. (For example, Australian English using the UTF-8 encoding is en_AU.UTF-8.)[2] Separately, ISO/IEC 15897 describes a different form, language_territory+audience+application,sponsor_version, though it's highly dubious whether it is used at all.[3]

In the next example there is an output of command `locale` for Czech language (cs), Czech Republic (CZ) with explicit UTF-8 encoding:

$ locale
LANG=cs_CZ.UTF-8
LC_CTYPE="cs_CZ.UTF-8"
LC_NUMERIC="cs_CZ.UTF-8"
LC_TIME="cs_CZ.UTF-8"
LC_COLLATE="cs_CZ.UTF-8"
LC_MONETARY="cs_CZ.UTF-8"
LC_MESSAGES="cs_CZ.UTF-8"
LC_PAPER="cs_CZ.UTF-8"
LC_NAME="cs_CZ.UTF-8"
LC_ADDRESS="cs_CZ.UTF-8"
LC_TELEPHONE="cs_CZ.UTF-8"
LC_MEASUREMENT="cs_CZ.UTF-8"
LC_IDENTIFICATION="cs_CZ.UTF-8"
LC_ALL=

## Specifics for Microsoft platforms

This book may need to be updated to reflect current knowledge.
section

|

Windows uses specific language and territory strings. The locale identifier (LCID) for unmanaged code on Microsoft Windows is a number such as 1033 for English (United States), or 2057 for English (United Kingdom), or 1041 for Japanese (Japan). These numbers consist of a language code (lower 10 bits) and a culture code (upper bits), and are therefore often written in hexadecimal notation, such as 0x0409, 0x0809 or 0x0411. Microsoft is starting to introduce managed code application programming interfaces (APIs) for .NET that use this format. One of the first to be generally released is a function to mitigate issues with internationalized domain names,[4] but more are in Windows Vista Beta 1.

Starting with Windows Vista, new functions[5] that use BCP 47 locale names have been introduced to replace nearly all LCID-based APIs.

A POSIX-like locale name format of language[_country-region[.code-page]] is available in the UCRT (Universal C Run Time) of Windows 10 and 11.[6]

## See also

* Internationalization and localization
* ISO 639 language codes
* ISO 3166-1 alpha-2 region codes
* ISO 15924 script codes
* IETF language tag
* C localization functions
* CCSID
* Code page
* Common Locale Data Repository
* Date and time representation by country
* AppLocale

## References

1. ↑ "LC_ALL, LC_COLLATE, LC_CTYPE, LC_MONETARY, LC_NUMERIC, LC_TIME - cppreference.com". https://en.cppreference.com/w/c/locale/LC_categories.
2. ↑ "Environment Variables". https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html.
3. ↑ "ISO/IEC JTC1/SC22 N610 [draft ISO/IEC 15897:1998(E) Information technology — Procedures for registration of cultural elements"]. 1998-11-17. https://www.open-std.org/jtc1/sc22/wg20/docs/n610.pdf. "For Narrative Cultural Specifications and POSIX Locales the token identifier will be: 8_9+11+12,13_14"
4. ↑ "DownlevelGetLocaleScripts function (Windows)". MSDN. Microsoft. https://msdn.microsoft.com/library/windows/desktop/dd317795.aspx. Retrieved 2017-12-11.
5. ↑ "Locale Names (Windows)". MSDN. Microsoft. https://docs.microsoft.com/en-us/windows/win32/intl/locale-names. Retrieved 2017-12-11.
6. ↑ "Locale Names, Languages, and Country-Region Strings" (in en-us). 19 October 2022. https://learn.microsoft.com/en-us/cpp/c-runtime-library/locale-names-languages-and-country-region-strings?view=msvc-140.

## External links

This article's use of external links may not follow Wikipedia's policies or guidelines. Please improve this article by removing excessive or inappropriate external links, and converting useful links where appropriate into footnote references. (September 2019) (Learn how and when to remove this template message)

|

* BCP 47
* Language Subtag Registry
* Common Locale Data Repository
* `java.util.Locale` Javadoc API documentation
* Locale and Language information from Microsoft
* MS-LCID: Windows Language Code Identifier (LCID) Reference from Microsoft
* Microsoft LCID list
* Microsoft LCID chart with decimal equivalents
* POSIX Environment Variables
* Low Level Technical details on defining a POSIX locale
* ICU Locale Explorer
* Debian Wiki on Locales
* Article "The Standard C++ Locale" by Nathan C. Myers
* locale(7): Description of multi-language support \- Linux man page
* Apache C++ Standard Library Locale User's Guide
* Sort order charts for various operating system locales and database collations
* NATSPEC Library
* Description of locale-related UNIX environment variables in Debian Linux Reference Manual
* Guides to locales and locale creation on various platforms

0.00

(0 votes)

|

Retrieved from "https://handwiki.org/wiki/index.php?title=Software:Locale_(computer_software)&oldid=704907"