Locale

Locales are used by glibc and other locale-aware programs or libraries for rendering text, correctly displaying regional monetary values, time and date formats, alphabetic idiosyncrasies, and other locale-specific standards.

Before a locale can be enabled on the system, it must be generated. This can be achieved by uncommenting applicable entries in /etc/locale.gen, and running locale-gen. Equivalently, commenting entries disables their respective locales. While making changes, consider any localisations required by other users on the system, as well as specific #Variables.

Setting the locale

To display the currently set locale and its related environmental settings, type:

$ locale

The locale to be used, chosen among the previously generated ones, is set in locale.conf files. Each of these files must contain a new-line separated list of environment variable assignments, having the same format as output by locale.

Overriding system locale per user session

The system-wide locale can be overridden in each user session by creating or editing ~/.config/locale.conf (or, in general, $XDG_CONFIG_HOME/locale.conf or $HOME/.config/locale.conf).

The precedence of these locale.conf files is defined in /etc/profile.d/locale.sh.

Tip:

This can also allow keeping the logs in /var/log in English while using the local language in the user environment.

You can create a /etc/skel/.config/locale.conf file so that any new users added using useradd and the -m option will have ~/.config/locale.conf automatically generated.

Make locale changes immediate

Once system and user locale.conf files have been created or edited, their new values will take effect for new sessions at login. To have the current environment use the new settings unset LANG and source /etc/profile.d/locale.sh:

$ unset LANG
$ source /etc/profile.d/locale.sh

Note: The LANG variable has to be unset first, otherwise locale.sh will not update the values from locale.conf. Only new and changed variables will be updated; variables removed from locale.conf will still be set in the session.

Variables

Full meaning of the above LC_* variables can be found on manpage locale(7), whereas details of their definition are described on locale(5).

LANG: default locale

The locale set for this variable will be used for all the LC_* variables that are not explicitly set.

LANGUAGE: fallback locales

Programs which use gettext for translations respect the LANGUAGE option in addition to the usual variables. This allows users to specify a list of locales that will be used in that order. If a translation for the preferred locale is unavailable, another from a similar locale will be used instead of the default. For example, an Australian user might want to fall back to British rather than US spelling:

locale.conf

LANG=en_AU.UTF-8
LANGUAGE=en_AU:en_GB:en

LC_TIME: date and time format

If LC_TIME is set to en_US.UTF-8, for example, the date format will be "MM/DD/YYYY". If wanting to use the the ISO 8601 date format of "YYYY-MM-DD" use:

locale.conf

LC_TIME=en_DK.UTF-8

Note: Programs do not necessarily respect this variable to format the date. For example, date(1) uses its own parameters to do so.

LC_COLLATE: collation

This variable governs the collation rules used for sorting and regular expressions.

Setting the value to C can for example make the ls command sort dotfiles first, followed by uppercase and lowercase filenames:

Troubleshooting

My terminal does not support UTF-8

xterm - Run with the argument -u8 or configure resource xterm*utf8: 2.

Gnome-terminal or rxvt-unicode

You need to launch these applications from a UTF-8 locale or they will drop UTF-8 support. Enable the en_US.UTF-8 locale (or your local UTF-8 alternative) per the instructions above and set it as the default locale, then reboot.

My system is still using wrong language

If you're using a desktop environment, such as GNOME, its language settings may be overriding the settings in locale.conf.

KDE Plasma also allows to change the UI's language through the system settings. If the desktop environment is still using the default language after the modification, deleting the file at~/.config/plasma-localerc (previously: ~/.config/plasma-locale-settings.sh) should resolve the issue.