Setting Your Locale
The following "how to" is taken from the Arch Wiki https://wiki.archlinux.org/index.php/Locale
Locales are used in Linux to define which language the user uses. As the locales define the character sets being used as well, setting up the correct locale is especially important if the language contains non-ASCII characters.
Locale names are defined using the following format:
Enabling necessary locales
Before a locale can be used on the system, it has to be enabled first. To list all available locales, use:
$ locale -a
To enable a locale, uncomment the name of the locale in the file /etc/locale.gen. This file contains all the available locales that can be used on the system. Revert the process to disable a locale. After the necessary locales are enabled, the system needs to be updated with the new locales:
To display the locales now currently in use, use:
English UTF-8 example
To setup an English UTF-8 conform system, the locale en_US.UTF-8 needs to be enabled. But for compatibility to programs that don't support UTF-8 yet, it's recommended to enable any other locale prefixed with en_US as well.
First uncomment the following locales in /etc/locale.gen:
en_US.UTF-8 UTF-8 en_US ISO-8859-1
Then update the system as root:
Setting system-wide locale
To define the system-wide locale used on the system, add the specified locale to the /etc/rc.conf file:
The system wide locale will be updated after rebooting the system.
Setting per user locale
As we mentioned earlier, some users might want to define a different locale than the system-wide locale. To do this, export the variable LANG with the specified locale in the ~/.bashrc file. For example, to use the en_AU.UTF-8 locale:
The locales will be updated next time ~/.bashrc is sourced. To update, either re-login or source it manually:
$ . ~/.bashrc
Collation, or sorting, is a little different. Sorting is a goofy beast and different locales do things differently. To get around potential issues, Arch used to set LC_COLLATE="C" in /etc/profile. However, this method is now deprecated. To enable this behavior, simply add the following to ~/.bashrc:
Now the ls command will sort dotfiles first, followed by uppercase and lowercase filenames. Note that without a LC_COLLATE setting, locale aware apps sort by LC_ALL or LOCALE, but LC_COLLATE settings will be overridden if LC_ALL is set. To resolve this, add the following to your instead:
export LC_ALL= export LC_COLLATE="C"
Setting starting weekday
In a lot of countries the first day of the week is Monday. To do change or add the following lines under the LC_TIME section in /usr/share/i18n/locales/<your_locale>:
week 7;19971130;5 first_weekday 2 first_workday 2
And then update the system:
My terminal doesn't support UTF-8
Unfortunately some terminals don't support UTF-8. In this case, you have to use a different terminal. Here are some terminals that have support for UTF-8:
- urxvt (rxvt-unicode)
Xterm doesn't support UTF-8
xterm only supports UTF-8 if you run it as uxterm or xterm -u8.
Gnome-terminal doesn't support UTF-8
Append these two lines to the /etc/environment file:
Reboot your system, and gnome-terminal should work correctly.
- Gentoo Linux Localization Guide
- Gentoo Wiki Archives: Locales
- ICU's interactive collation testing
- Free Standards Group Open Internationalisation Initiative
Back to Table of Contents