Locale (computer software)

Revision as of 16:06, 21 April 2025 by imported>R'n'B (Disambiguating links to ANSI character set (link changed to Windows code pages) using DisamAssist.)
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)

Template:Short description {{#invoke:other uses|otheruses}}

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.

General locale settingsEdit

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)
  • 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 supportEdit

In these environments,

Template:Div col

Template: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 standardsEdit

In standard C and C++, locale is defined in "categories" of Template:Tt (text collation), Template:Tt (character class), Template:Tt (currency format), Template:Tt (number format), and Template:Tt (time format). The special Template:Tt category can be used to set all locale settings.<ref>{{#invoke:citation/CS1|citation |CitationClass=web }}</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 platformsEdit

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 Template:Mono. (For example, Australian English using the UTF-8 encoding is Template:Mono.)<ref>{{#invoke:citation/CS1|citation |CitationClass=web }}</ref> Separately, ISO/IEC 15897 describes a different form, Template:Mono, though it's highly dubious whether it is used at all.<ref>{{#invoke:citation/CS1|citation |CitationClass=web }}</ref>

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 platformsEdit

Template:Outdated

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,<ref>{{#invoke:citation/CS1|citation |CitationClass=web }}</ref> but more are in Windows Vista Beta 1.

Starting with Windows Vista, new functions<ref name="microsoft">{{#invoke:citation/CS1|citation |CitationClass=web }}</ref> that use BCP 47 locale names have been introduced to replace nearly all LCID-based APIs.

A POSIX-like locale name format of Template:Mono is available in the UCRT (Universal C Run Time) of Windows 10 and 11.<ref>{{#invoke:citation/CS1|citation |CitationClass=web }}</ref>

See alsoEdit

ReferencesEdit

Template:Reflist

External linksEdit

Template:Linkfarm Template:Sister project