locale(7)
๐ locale(7) ๐
description of multilanguage support โ and bestie, it's giving everything ๐ฆ
โจ NAME โจ
locale โ description of multilanguage support. that's the whole assignment ๐ซถ
๐ธ SYNOPSIS ๐ธ
#include <locale.h>
๐ DESCRIPTION ๐
okay so. a locale is literally just a set of language and cultural rules bundled up together. these rules cover stuff like what language your messages come out in, the different character sets, lexicographic conventions, and so on and so forth โจ. and the tea is: a program needs to be able to figure out its own locale and act accordingly, otherwise it is simply not portable to different cultures. no cap.
the header <locale.h> declares all the data types, functions, and macros that are useful for this whole task ๐
.
the functions it declares are setlocale(3) โ which sets the current locale โ and localeconv(3) โ which gets you information about number formatting.
then there's the categories. there are different categories for locale information that a program might need, and they're declared as macros. use them as the first argument to setlocale(3) and you can set one of these to the locale you want:
LC_ADDRESS(GNU extension, since glibc 2.2) โ changes the settings that describe the formats (like postal addresses) used to describe locations and geography-related items. apps that need this info can usenl_langinfo(3)to pull nonstandard elements, such as_NL_ADDRESS_COUNTRY_NAME(country name, in the language of the locale) and_NL_ADDRESS_LANG_NAME(language name, in the language of the locale), which return strings such as"Deutschland"and"Deutsch"(for German-language locales). (other element names are listed in<langinfo.h>.)LC_COLLATEโ this category governs the collation rules used for sorting and regular expressions, including character equivalence classes and multicharacter collating elements. this locale category changes the behavior of the functionsstrcoll(3)andstrxfrm(3), which are used to compare strings in the local alphabet. for example, the German sharp s is sorted as"ss"๐ฅLC_CTYPEโ this category determines the interpretation of byte sequences as characters (single versus multibyte characters, that whole situation), character classifications (alphabetic or digit, etc.), and the behavior of character classes. on glibc systems, this category also determines the character transliteration rules foriconv(1)andiconv(3). it changes the behavior of the character handling and classification functions, such asisupper(3)andtoupper(3), and the multibyte character functions such asmblen(3)orwctomb(3).LC_IDENTIFICATION(GNU extension, since glibc 2.2) โ changes the settings that relate to the metadata for the locale. apps that need this info can usenl_langinfo(3)to pull nonstandard elements, such as_NL_IDENTIFICATION_TITLE(title of this locale document) and_NL_IDENTIFICATION_TERRITORY(geographical territory to which this locale document applies), which might return strings such as"English locale for the USA"and"USA". (other element names are listed in<langinfo.h>.)LC_MONETARYโ this category determines the formatting used for monetary-related numeric values. it changes the info returned bylocaleconv(3), which describes the way numbers are usually printed, with details like decimal point versus decimal comma ๐ธ. this info is internally used by the functionstrfmon(3).LC_MESSAGESโ this category affects the language in which messages are displayed, and what an affirmative or negative answer looks like. the GNU C library contains thegettext(3),ngettext(3), andrpmatch(3)functions to make using this info easier. the GNU gettext family of functions also obeys the environment variableLANGUAGE(which holds a colon-separated list of locales) if the category is set to a valid locale other than"C". this category also affects the behavior ofcatopen(3).LC_MEASUREMENT(GNU extension, since glibc 2.2) โ change the settings relating to the measurement system in the locale (i.e., metric versus US customary units). apps can usenl_langinfo(3)to retrieve the nonstandard_NL_MEASUREMENT_MEASUREMENTelement, which returns a pointer to a character that has the value1(metric) or2(US customary units) ๐LC_NAME(GNU extension, since glibc 2.2) โ change the settings that describe the formats used to address persons. apps that need this info can usenl_langinfo(3)to retrieve nonstandard elements, such as_NL_NAME_NAME_MR(general salutation for men) and_NL_NAME_NAME_MS(general salutation for women) elements, which return strings such as"Herr"and"Frau"(for German-language locales). (other element names are listed in<langinfo.h>.)LC_NUMERICโ this category determines the formatting rules used for nonmonetary numeric values โ for example, the thousands separator and the radix character (a period in most English-speaking countries, but a comma in many other regions). it affects functions such asprintf(3),scanf(3), andstrtod(3). this info can also be read with thelocaleconv(3)function.LC_PAPER(GNU extension, since glibc 2.2) โ change the settings relating to the dimensions of the standard paper size (e.g., US letter versus A4). apps that need the dimensions can get them by usingnl_langinfo(3)to retrieve the nonstandard_NL_PAPER_WIDTHand_NL_PAPER_HEIGHTelements, which returnintvalues specifying the dimensions in millimeters ๐LC_TELEPHONE(GNU extension, since glibc 2.2) โ change the settings that describe the formats to be used with telephone services. apps that need this info can usenl_langinfo(3)to retrieve nonstandard elements, such as_NL_TELEPHONE_INT_PREFIX(international prefix used to call numbers in this locale), which returns a string such as"49"(for Germany). (other element names are listed in<langinfo.h>.) โ๏ธLC_TIMEโ this category governs the formatting used for date and time values. for example, most of Europe uses a 24-hour clock versus the 12-hour clock used in the United States. the setting of this category affects the behavior of functions such asstrftime(3)andstrptime(3)๐ฐ๏ธLC_ALLโ all of the above. yeah, the whole squad ๐
if the second argument to setlocale(3) is an empty string, "", for the default locale, it gets determined using these steps:
- if there is a non-null environment variable
LC_ALL, the value ofLC_ALLis used. - if an environment variable with the same name as one of the categories above exists and is non-null, its value is used for that category.
- if there is a non-null environment variable
LANG, the value ofLANGis used.
values about local numeric formatting are made available in a struct lconv returned by the localeconv(3) function, which has this declaration:
struct lconv {
/* Numeric (nonmonetary) information */
char *decimal_point; /* Radix character */
char *thousands_sep; /* Separator for digit groups to left
of radix character */
char *grouping; /* Each element is the number of digits in
a group; elements with higher indices
are further left. An element with value
CHAR_MAX means that no further grouping
is done. An element with value 0 means
that the previous element is used for
all groups further left. */
/* Remaining fields are for monetary information */
char *int_curr_symbol; /* First three chars are a currency
symbol from ISO 4217. Fourth char
is the separator. Fifth char
is '\0'. */
char *currency_symbol; /* Local currency symbol */
char *mon_decimal_point; /* Radix character */
char *mon_thousands_sep; /* Like thousands_sep above */
char *mon_grouping; /* Like grouping above */
char *positive_sign; /* Sign for positive values */
char *negative_sign; /* Sign for negative values */
char int_frac_digits; /* International fractional digits */
char frac_digits; /* Local fractional digits */
char p_cs_precedes; /* 1 if currency_symbol precedes a
positive value, 0 if succeeds */
char p_sep_by_space; /* 1 if a space separates
currency_symbol from a positive
value */
char n_cs_precedes; /* 1 if currency_symbol precedes a
negative value, 0 if succeeds */
char n_sep_by_space; /* 1 if a space separates
currency_symbol from a negative
value */
/* Positive and negative sign positions:
0 Parentheses surround the quantity and currency_symbol.
1 The sign string precedes the quantity and currency_symbol.
2 The sign string succeeds the quantity and currency_symbol.
3 The sign string immediately precedes the currency_symbol.
4 The sign string immediately succeeds the currency_symbol. */
char p_sign_posn;
char n_sign_posn;
};
๐ง POSIX.1-2008 extensions to the locale API ๐ง
POSIX.1-2008 standardized a bunch of extensions to the locale API, based on implementations that first appeared in glibc 2.3. these extensions exist specifically to address the problem that the traditional locale APIs do not mix well with multithreaded applications, or with applications that have to deal with multiple locales at once ๐ญ
the extensions take the form of new functions for creating and manipulating locale objects (newlocale(3), freelocale(3), duplocale(3), and uselocale(3)) plus various new library functions with the suffix "_l" (e.g., toupper_l(3)) that extend the traditional locale-dependent APIs (e.g., toupper(3)) so you can specify a locale object that should apply when executing the function โจ
๐ ENVIRONMENT ๐
okay so bestie, there's literally one environment variable doing the heavy lifting here, and it's giving main character energy for locale discovery:
LOCPATHโ this one is used bynewlocale(3)andsetlocale(3), so it affects all unprivileged localized programs. It's a list of pathnames, separated by colons (':'), that should be used to find locale data. If this variable is set, only the individual compiled locale data files fromLOCPATHand the system default locale data path are used; any available locale archives are not used (seelocaledef(1)). The individual compiled locale data files are searched for under subdirectories which depend on the currently used locale. For example, whenen_GB.UTF-8is used for a category, the following subdirectories are searched for, in this order:en_GB.UTF-8,en_GB.utf8,en_GB,en.UTF-8,en.utf8, anden.
That's it. slay.
๐๏ธ FILES ๐๏ธ
/usr/lib/locale/locale-archiveโ usual default locale archive location. No cap./usr/lib/localeโ usual default path for compiled individual locale files. Periodt.
๐ STANDARDS ๐
POSIX.1-2001. That's the one, bestie. It's giving certified.
๐ SEE ALSO ๐
go read these next, okay? They're all part of the locale cinematic universe:
iconv(1)locale(1)localedef(1)catopen(3)gettext(3)iconv(3)localeconv(3)mbstowcs(3)newlocale(3)ngettext(3)nl_langinfo(3)rpmatch(3)setlocale(3)strcoll(3)strfmon(3)strftime(3)strxfrm(3)uselocale(3)wcstombs(3)locale(5)charsets(7)unicode(7)utf-8(7)
and that's the whole vibe check, bestie. This page came from Linux man-pages 6.20, dated 2026-02-08, and it's literally the locale(7) manual page. Obsessed. ๐
โจ
๐ฆ where this page comes from
- arch rolling: man-pages 6.20-1 ยท BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages 6.20
- ๐ the page's license: Linux-man-pages-copyleft
- Copyright 1993, Thomas Koenig <ig25@rz.uni-karlsruhe.de>
- Copyright 2014, Michael Kerrisk <mtk.manpages@gmail.com>
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms