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 use nl_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 functions strcoll(3) and strxfrm(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 for iconv(1) and iconv(3). it changes the behavior of the character handling and classification functions, such as isupper(3) and toupper(3), and the multibyte character functions such as mblen(3) or wctomb(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 use nl_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 by localeconv(3), which describes the way numbers are usually printed, with details like decimal point versus decimal comma ๐Ÿ’ธ. this info is internally used by the function strfmon(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 the gettext(3), ngettext(3), and rpmatch(3) functions to make using this info easier. the GNU gettext family of functions also obeys the environment variable LANGUAGE (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 of catopen(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 use nl_langinfo(3) to retrieve the nonstandard _NL_MEASUREMENT_MEASUREMENT element, which returns a pointer to a character that has the value 1 (metric) or 2 (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 use nl_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 as printf(3), scanf(3), and strtod(3). this info can also be read with the localeconv(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 using nl_langinfo(3) to retrieve the nonstandard _NL_PAPER_WIDTH and _NL_PAPER_HEIGHT elements, which return int values 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 use nl_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 as strftime(3) and strptime(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:

  1. if there is a non-null environment variable LC_ALL, the value of LC_ALL is used.
  2. 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.
  3. if there is a non-null environment variable LANG, the value of LANG is 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 by newlocale(3) and setlocale(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 from LOCPATH and the system default locale data path are used; any available locale archives are not used (see localedef(1)). The individual compiled locale data files are searched for under subdirectories which depend on the currently used locale. For example, when en_GB.UTF-8 is 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, and en.

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:


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
  • ๐Ÿ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms