From ArchWiki
Revision as of 14:29, 22 August 2016 by Nl6720 (talk | contribs) (use Template:man)
Jump to navigation Jump to search


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.

Generating locales

Before a locale can be enabled on the system, it has to be generated. The current generated/available locales can be viewed with:

$ locale -a

The locales that can be generated are listed in the /etc/locale.gen file: their names are defined using the format [language][_TERRITORY][.CODESET][@modifier]. To generate a locale, first uncomment the corresponding line in the file (or comment to remove); when doing this, also consider localizations needed by other users on the system and specific #Variables. For example, for American-English uncomment en_US.UTF-8 UTF-8.

#en_SG ISO-8859-1
en_US.UTF-8 UTF-8
#en_US ISO-8859-1

When done, save the file and generate the uncommented locale(s) by executing:

# locale-gen
  • locale-gen also runs with every update of glibc. [1]
  • UTF-8 is recommended over other options. [2]

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 which must contain a new-line separated list of environment variable assignments having the same format as output by locale.

To list available locales that can be used which have been previously generated do:

$ localectl list-locales

Setting the system locale

To set the system locale use the localectl command, where en_US.UTF-8 is from the first column of an uncommented entry in /etc/locale.gen.

# localectl set-locale LANG=en_US.UTF-8
Note: localectl cannot be used to set the system locale in the installation chroot environment. /etc/locale.conf must be edited manually as follows.

Alternatively, manually edit or create /etc/locale.conf:


See #Variables, locale.conf(5) and related for details.

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.

  • 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:

$ 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.

Other uses

Locale variables can also be defined with the standard methods as explained in Environment variables.

For example, in order to test or debug a particular application during development, it could be launched with something like:

$ LANG=C ./my_application.sh

Similarly, to set the locale for all processes run from the current shell (for example, during system installation):

$ export LANG=C


locale.conf files support the following environment variables:

  • LANG

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:


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:


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:


See also [3].

To get around potential issues, Arch used to set LC_COLLATE=C in /etc/profile, but this method is now deprecated.

LC_ALL: troubleshooting

The locale set for this variable will always override LANG and all the other LC_* variables, whether they are set or not.

LC_ALL is the only LC_* variable, which cannot be set in locale.conf files: it is meant to be used only for testing or troubleshooting purposes, for example in /etc/profile.


My terminal does not support UTF-8

The following lists some (not all) terminals that support UTF-8:

Gnome-terminal or rxvt-unicode does not support UTF-8

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

It is possible that the environment variables are redefined in other files than locale.conf, for example ~/.pam_environment. See Environment variables#Defining variables for details.

See also