A locale in computing is a set of parameters that describes the language and cultural conventions software uses when processing and presenting information. It may determine number and currency formats, date and time formats, sorting rules, character classification, and the language of interface messages. An operating system, application, or individual operation may use a particular locale. A locale represents a collection of conventions rather than a user’s physical location, nationality, or complete set of personal preferences.
Scope and purpose
Locale support allows software to handle information according to conventions familiar to different audiences without maintaining a separate implementation for every audience. The same numeric value, for example, can be displayed as 1,234.56 under typical United States English conventions and 1.234,56 under typical German conventions.
Locale-sensitive behavior commonly includes:
| Area | Examples of locale-dependent behavior |
|---|---|
| Numbers | Decimal separators, grouping separators, grouping sizes, digit shapes, and percentage formats |
| Currency | Currency symbol placement, spacing, negative-value patterns, and default currency |
| Dates and times | Field order, month names, hour cycles, calendars, and first day of the week |
| Text processing | Case conversion, character classification, and word or sentence boundaries |
| Sorting and searching | Alphabetical order, treatment of accents, and distinctions between letter variants |
| Messages | Selection of translated interface text and grammatical plural forms |
| Measurement | Preferred measurement systems and localized unit names |
Not every locale system covers every area. Some environments offer only a small set of formatting and character-handling categories; others expose extensive cultural data.
Locale is closely related to internationalization, the design of software so it can support different languages and conventions, and localization, its adaptation for a particular audience. A locale supplies identifiers and rules used in those processes, but does not itself provide a complete translated application.
Locale identifiers
A locale identifier names a collection of preferences. Its exact syntax depends on the platform or standard.
Language tags and Unicode locale identifiers
Modern systems often use identifiers based on BCP 47 language tags. These can identify a language, a writing system, a region, and additional variants. Examples include:
en-US: English associated with the United States.en-GB: English associated with the United Kingdom.pt-BR: Portuguese associated with Brazil.sr-Latn-RS: Serbian written in the Latin script, associated with Serbia.zh-Hant-TW: Chinese written in the traditional script, associated with Taiwan.
A language tag is not necessarily a complete locale specification. A tag such as en identifies a language without explicitly choosing a region. Software may infer additional preferences from defaults or supplementary data.
Unicode locale identifiers build on language-tag conventions and can include extensions for particular preferences. For example, en-US-u-hc-h23 requests a 24-hour cycle using hours numbered from 0 to 23. Extensions can also identify preferences such as a calendar, numbering system, or collation type.
These identifiers separate concepts that are often incorrectly treated as interchangeable. A language can be used in many regions, and a region can contain users of many languages and writing systems.
POSIX-style locale names
On many Unix and Linux systems, locale names commonly follow a form such as:
language_TERRITORY.codeset@modifier
An example is en_US.UTF-8. In this naming convention, UTF-8 identifies a character encoding, rather than a language or cultural convention.
These names are implementation-dependent and are not interchangeable with BCP 47 tags. The availability of a name may depend on which locale definitions have been installed or generated. A system can therefore recognize a language conceptually while rejecting a particular locale name.
Locale data and processing
A locale identifier is a key into data and algorithms, not a complete description of the required behavior. Locale-aware software normally combines several components:
- Locale data, such as month names, number symbols, and date patterns.
- Processing algorithms, such as formatting, text segmentation, and comparison.
- Resource selection, which chooses translated messages or other localized content.
- Application preferences, which may override selected defaults.
The Common Locale Data Repository (CLDR), maintained by the Unicode Consortium, supplies widely used language and regional data. International Components for Unicode (ICU) provides libraries that implement locale-sensitive services using Unicode standards and CLDR data.
Locale data is versioned and can change. Updates may revise translated names, regional conventions, or formatting patterns. Consequently, two implementations using the same locale identifier can produce different output if they use different data versions, defaults, or supported options.
Formatting and parsing
Formatting converts an internal value into a presentation suitable for an audience. Parsing attempts the reverse conversion.
For example, the string 1,234 can represent one thousand two hundred thirty-four or a decimal value, depending on the conventions in use. The date 03/04/2025 is similarly ambiguous without a specified date order.
Locale-aware formatting does not necessarily imply equally flexible or unambiguous parsing. Some libraries format dates extensively but provide limited parsing facilities. A formatted string may also discard information, such as fractional seconds or the precision of a number, so formatting and parsing need not be exact inverses.
Collation and case conversion
Collation is the ordering of text according to a defined set of comparison rules. It differs from sorting strings solely by their numeric Unicode values. Languages may order accented letters differently or treat particular combinations of letters as units.
Locale-sensitive comparison can be configured to consider or ignore distinctions such as accents and letter case. In a database, the selected collation may therefore affect ordering, searches, and whether two values count as equal for a uniqueness constraint.
Case conversion can also depend on locale. Turkish, for example, distinguishes dotted and dotless forms of the letter I in a way that differs from English casing rules. Lowercasing text is therefore not a universally reliable method of producing language-independent identifiers.
Operating-system and programming interfaces
C and POSIX locales
The C programming language and POSIX define locale categories so that different types of behavior can be configured separately. Core categories include:
LC_CTYPE: character classification and case conversion, together with aspects of multibyte-character handling.LC_COLLATE: string collation.LC_NUMERIC: nonmonetary numeric formatting.LC_MONETARY: monetary formatting.LC_TIME: date and time formatting.
POSIX also defines LC_MESSAGES for message-related conventions. LC_ALL selects all categories for relevant interfaces.
In POSIX environments, the environment variable LC_ALL, when set to a nonempty value, overrides the category-specific variables. Those variables in turn override LANG. Programs generally activate environment-selected locales through calls such as setlocale(LC_ALL, ""); merely defining environment variables does not guarantee that every program will use them.
The standard C locale provides a minimal, predictable baseline. C programs begin in this locale unless they change it. On POSIX systems, POSIX is an equivalent locale name. Locales named C.UTF-8 are available on some systems, but their presence and exact behavior are implementation-dependent.
Traditional setlocale usage changes shared locale state. Changing that state while other threads perform locale-dependent operations can cause concurrency problems. Some interfaces provide thread-specific locales or accept an explicit locale object, allowing behavior to be scoped more narrowly.
Explicit locale APIs
Many modern programming languages and libraries offer locale objects or formatting functions that accept a locale argument. This permits one application to produce output for several audiences without repeatedly changing a process-wide default.
In JavaScript, the Intl API provides locale-sensitive number and date formatting, collation, plural rules, and other services. Microsoft Windows provides locale-name-based interfaces, while other platforms expose their own locale objects and preference systems.
Explicit locale selection is especially important in server applications, where simultaneous requests may belong to users with different preferences.
Locale selection and fallback
A requested locale may not be available exactly as specified. Software therefore uses locale matching and fallback to select supported resources or conventions.
For translated resources, an application might try a region-specific language resource, then a general language resource, then its default language. Cultural-data inheritance can be more complex: CLDR defines parent relationships and other mechanisms that do not always correspond to simply removing the last component of an identifier.
Web applications may consider an account preference, a user selection, settings exposed by a web browser, or the Accept-Language request header in HTTP. These inputs indicate language preferences; they do not necessarily establish a user’s currency, time zone, or preferred date format.
A single user may prefer one language for interface text, another convention for numbers, and a particular calendar. Systems that support independent preferences can represent these choices more accurately than those that require one indivisible regional profile.
Distinctions and limitations
Locale is not encoding
UTF-8 specifies how Unicode characters are represented as bytes. It does not specify date formats, decimal separators, sorting rules, or message languages. Many different locales can use the same encoding.
The association of encoding with locale names in older systems reflects historical implementation choices, not an inherent identity between the two concepts.
Locale is not a time zone
A locale influences how a date or time is displayed; a time zone determines the applicable civil-time offset and transition rules for an instant. A person using en-US may be located in any time zone. Correct date-time presentation may require the instant, time zone, calendar, locale, and user-specific options.
Locale is not a data-interchange format
Localized presentation can be ambiguous and unstable across environments. Machine-readable formats and network protocols therefore often prescribe locale-independent representations. For example, JSON numbers use a period as the decimal separator regardless of the user’s display preferences.
Confusing presentation formats with storage or interchange formats can produce parsing failures or altered values. Locale-sensitive comparison can likewise be inappropriate where a protocol requires exact identifier matching.
Locale defaults do not describe every user
Locale data records conventions and defaults, not universal behavior within a population. Preferences vary among individuals and across professional, administrative, and social contexts. A locale also does not by itself supply translated content, appropriate fonts, keyboard layouts, or a complete right-to-left interface. These depend on additional resources and application behavior.