For the complete documentation index, see llms.txt. This page is also available as Markdown.

12.1 Localization Environment Variables

Localization environment variables (LANG, LC_*, MM_CHARSET) determine the system interface language, character encoding, and sorting rules. This section describes configuration methods for various scenarios.

Localization Environment Variable Configuration File Paths

Display Manager Configuration Paths

Display Manager
Configuration File Path

SDDM, LightDM, GDM

~/.xprofile

LightDM, GDM

~/.profile

SDDM

User login Shell configuration file

Shell Configuration Paths

Shell
Configuration File Path

sh

~/.profile

bash

~/.bash_profile or ~/.profile

zsh

~/.zprofile

csh

~/.cshrc

The LC_* family of variables are core environment variables used in UNIX and UNIX-like operating systems to implement internationalization (i18n) and localization (l10n). LC_COLLATE, LC_CTYPE, LC_MESSAGES, LC_MONETARY, LC_NUMERIC, LC_TIME, as well as LC_ALL and LANG, are defined by the POSIX (IEEE Std 1003.1, i.e., ISO/IEC 9945) standard. LC_ADDRESS, LC_NAME, LC_PAPER, LC_TELEPHONE, LC_MEASUREMENT, and LC_IDENTIFICATION are GNU extensions of glibc (introduced since glibc 2.2). ISO/IEC TR 30112:2014 (a technical report, now withdrawn, later superseded by the ISO/IEC 30112:2020 international standard) referenced these existing practices during its development (see Debian manpages. locale(7)[EB/OL]. [2026-04-17]. https://manpages.debian.org/unstable/manpages/locale.7.en.html). These variables control localization behavior across multiple dimensions including text character encoding, date and time formats, currency symbols, and interface language.

Variable
Description

LC_COLLATE

Defines the rules for string collation

LC_CTYPE

Defines the character set and character type classification rules, such as letters, digits, punctuation marks, etc.

LC_MONETARY

Defines the monetary format and currency symbol

LC_MESSAGES

Defines the language of program runtime output messages

LC_NUMERIC

Defines the numeric format, such as decimal point and thousands separator

LC_TIME

Defines the date and time format

LC_ADDRESS

Defines the address format

LC_NAME

Defines the personal name format

LC_PAPER

Defines the default paper size

LC_TELEPHONE

Defines the telephone number format

LC_MEASUREMENT

Defines the measurement unit format (metric or imperial)

LC_IDENTIFICATION

Defines metadata about the locale itself (locale name, language, region, currency, and other identification information)

MM_CHARSET

Sets the MIME character set, used by applications to determine character encoding when processing multilingual content

Special Variable Descriptions

Variable
Description

LC_ALL

Setting this variable overrides the values of all other LC_* variables simultaneously

LANG

Used to set the default language and character set, typically providing locale information when no other LC_* variables are set. If both LANG and LC_* variables are set, the LC_* variables will override the corresponding settings in the LANG variable

LANGUAGE

Primarily used to specify the preferred language for interface messages (such as command-line prompts, error messages, menu text, etc.) for localization libraries like GNU gettext. GNU gettext gives LANGUAGE higher priority than LC_ALL and LANG. It generally does not affect date, number, or currency formats; these format-related localizations are still controlled by the corresponding LC_TIME, LC_NUMERIC, LC_MONETARY, and other LC_* variables or LANG. If LANGUAGE is not set, programs typically fall back to LC_MESSAGES or other locale variables to determine the interface message language

References

Common Configuration Schemes

A Chinese language environment can be achieved through multiple approaches:

  1. Setting only LC_MESSAGES to zh_CN.UTF-8 is sufficient for a Chinese interface (verified in SDDM/Xfce environment)

  2. A common practice is to set all three environment variables LANG, LC_ALL, and LANGUAGE to zh_CN.UTF-8

  3. Keep the system interface in English while using a Chinese input method; set only input method-related variables and leave other environment variables at the default English settings

Different software may have varying priorities when reading localization variables, so it is recommended to set all three environment variables to zh_CN.UTF-8 to ensure consistency in language settings.

Different Configurations Produce Different Effects

When only LC_MESSAGES is set, this setting only affects the interface and prompt messages, and does not affect the output of other formats. Taking sh as an example:

Defaults:

  • LC_TIME environment variable value is C.UTF-8

  • date command outputs Fri Apr 21 21:14:43 UTC 2023

  • LC_TIME environment variable value is set to zh_CN.UTF-8

  • date command outputs 2023年 4月21日 星期五 21时15分07秒 UTC

Note

Keeping the date command's English output may be very important in certain scripts. Similar situations exist for other information controlled by LC_* variables.

Exercises

  1. Configure localization environment variables for different Shells (sh, bash, zsh, csh) on a FreeBSD system, and verify the output of the date command in English and Chinese environments respectively.

  2. Set up an environment with only LC_MESSAGES=zh_CN.UTF-8, and test the availability of Chinese prompts in common commands (such as ls, pkg, man).

  3. Analyze the priority relationships among LANG, LC_ALL, and various LC_* variables, and provide examples to illustrate the actual behavior under different setting combinations.

Last updated