Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Locale (computer software)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{Short description|Parameters defining locale in computer}} {{other uses|Locale (disambiguation)}} In [[computing]], a '''locale''' is a set of [[parameter]]s 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]]. == 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 temperature setting * UI font setting (especially for [[CJKV]] language) * Location setting (country or region) * [[Windows code pages|ANSI character set]] setting (for [[Microsoft Windows]]) 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, {{div col|colwidth=18em}} * [[C (programming language)|C]] * [[C++]] * [[Eiffel (programming language)|Eiffel]] * [[Java (programming language)|Java]] * [[.NET Framework]] * [[REBOL]] * [[Ruby (programming language)|Ruby]] * [[Perl]] * [[PHP]] * [[Python (programming language)|Python]] * [[XML]] * [[JavaServer Pages|JSP]] * [[JavaScript]] {{div col end}} 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 {{tt|LC_COLLATE}} (text collation), {{tt|LC_CTYPE}} (character class), {{tt|LC_MONETARY}} (currency format), {{tt|LC_NUMERIC}} (number format), and {{tt|LC_TIME}} (time format). The special {{tt|LC_ALL}} category can be used to set all locale settings.<ref>{{cite web |title=LC_ALL, LC_COLLATE, LC_CTYPE, LC_MONETARY, LC_NUMERIC, LC_TIME - cppreference.com |url=https://en.cppreference.com/w/c/locale/LC_categories |website=en.cppreference.com}}</ref> 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 {{mono|<nowiki>[language[_territory][.codeset][@modifier]]</nowiki>}}. (For example, [[Australian English]] using the [[UTF-8]] encoding is {{mono|en_AU.UTF-8}}.)<ref>{{cite web |title=Environment Variables |url=https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html |website=pubs.opengroup.org}}</ref> Separately, [[ISO/IEC 15897]] describes a different form, {{mono|<nowiki>language_territory+audience+application,sponsor_version</nowiki>}}, though it's highly dubious whether it is used at all.<ref>{{cite web |title=ISO/IEC JTC1/SC22 N610 [draft ISO/IEC 15897:1998(E)] Information technology β Procedures for registration of cultural elements |url=https://www.open-std.org/jtc1/sc22/wg20/docs/n610.pdf |access-date=8 June 2023 |date=1998-11-17|quote=For Narrative Cultural Specifications and POSIX Locales the token identifier will be: 8_9+11+12,13_14}}</ref> <!-- The identifier format is documented with the environment variables, but how do we cite (e.g.) SUSv4 here? Also, this seems to be part of an "optional" feature. ~~~~ --> In the next example there is an output of command <code>locale</code> 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 == {{outdated|section|date=June 2016}} Windows uses specific [https://web.archive.org/web/20170228045725/https://msdn.microsoft.com/en-us/library/39cwe7zf(vs.71).aspx language] and [https://web.archive.org/web/20160610104759/https://msdn.microsoft.com/en-us/library/cdax410z(VS.71).aspx territory] strings. The ''locale identifier'' (LCID) for [[managed code|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 interface]]s (APIs) for .NET that use this format. One of the first to be generally released is a function to mitigate issues with [[internationalized domain name]]s,<ref>{{cite web |url=https://msdn.microsoft.com/library/windows/desktop/dd317795.aspx |title=DownlevelGetLocaleScripts function (Windows) |work=[[Microsoft Developer Network|MSDN]] |publisher=[[Microsoft]] |accessdate=2017-12-11}}</ref> but more are in [[Windows Vista]] Beta 1. Starting with Windows Vista, new functions<ref name="microsoft">{{cite web |url=https://docs.microsoft.com/en-us/windows/win32/intl/locale-names |title=Locale Names (Windows) |work=[[Microsoft Developer Network|MSDN]] |publisher=[[Microsoft]] |accessdate=2017-12-11}}</ref> that use [[BCP 47]] locale names have been introduced to replace nearly all LCID-based APIs. A POSIX-like locale name format of {{mono|language[_country-region[.code-page]]}} is available in the UCRT (Universal C Run Time) of Windows 10 and 11.<ref>{{cite web |title=Locale Names, Languages, and Country-Region Strings |url=https://learn.microsoft.com/en-us/cpp/c-runtime-library/locale-names-languages-and-country-region-strings?view=msvc-140 |website=learn.microsoft.com |language=en-us |date=19 October 2022}}</ref> ==See also== * [[Internationalization and localization]] * [[ISO 639]] [[language code]]s * [[ISO 3166-1 alpha-2]] [[region code]]s * [[ISO 15924]] [[script code]]s * [[IETF language tag]] * [[C localization functions]] * [[CCSID]] * [[Code page]] * [[Common Locale Data Repository]] * [[Date and time representation by country]] * AppLocale ==References== {{Reflist}} == External links == {{linkfarm|date=September 2019}} {{wiktionary|locale}} * [http://tools.ietf.org/html/bcp47 BCP 47] * [https://www.iana.org/assignments/language-subtag-registry Language Subtag Registry] * [https://www.unicode.org/cldr/ Common Locale Data Repository] * {{Javadoc:SE|package=java.util|java/util|Locale}} [[Javadoc]] API documentation * [https://msdn.microsoft.com/en-us/library/dd318716 Locale and Language information from Microsoft] * [https://msdn.microsoft.com/en-us/library/cc233965.aspx MS-LCID: Windows Language Code Identifier (LCID) Reference from Microsoft] * [https://msdn.microsoft.com/en-us/library/cc233968.aspx Microsoft LCID list] * [https://msdn.microsoft.com/en-us/library/0h88fahh.aspx Microsoft LCID chart with decimal equivalents] * [http://www.opengroup.org/onlinepubs/007908799/xbd/envvar.html POSIX Environment Variables] * [http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap07.html Low Level Technical details on defining a POSIX locale] * [http://demo.icu-project.org/icu-bin/locexp ICU Locale Explorer] * [http://wiki.debian.org/Locale Debian Wiki on Locales] * Article "[http://cantrip.org/locale.html The Standard C++ Locale]" by [[Nathan C. Myers]] * [http://www.die.net/doc/linux/man/man7/locale.7.html locale(7): Description of multi-language support] - Linux man page * [http://incubator.apache.org/stdcxx/doc/stdlibug/VII.html Apache C++ Standard Library Locale User's Guide] * [https://web.archive.org/web/20110520132147/http://www.collation-charts.org/ Sort order charts for various operating system locales and database collations] * [http://www.freesource.info/wiki/Lokalizacija/NATSPECDescription NATSPEC Library] * [http://www.debian.org/doc/manuals/reference/ch-tune.en.html#s-env-locale Description of locale-related UNIX environment variables in Debian Linux Reference Manual] * [http://docs.translatehouse.org/projects/localization-guide/en/latest/guide/start.html?id=guide/start#locales Guides to locales and locale creation on various platforms] [[Category:Unix user management and support-related utilities]] [[Category:Unix SUS2008 utilities]] [[Category:Internationalization and localization]]
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)
Pages transcluded onto the current version of this page
(
help
)
:
Template:Cite web
(
edit
)
Template:Div col
(
edit
)
Template:Div col end
(
edit
)
Template:Javadoc:SE
(
edit
)
Template:Linkfarm
(
edit
)
Template:Mono
(
edit
)
Template:Other uses
(
edit
)
Template:Outdated
(
edit
)
Template:Reflist
(
edit
)
Template:Short description
(
edit
)
Template:Tt
(
edit
)
Template:Wiktionary
(
edit
)