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:
- 1 Enabling necessary locales
- 2 Setting system-wide locale
- 3 Setting per user locale
- 4 Setting collation
- 5 Setting starting weekday
- 6 Troubleshooting
- 7 More resources
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 Template:Filename. 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 Template:Filename:
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 Template:Filename 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 Template:Codeline with the specified locale in the Template:Filename file. For example, to use the en_AU.UTF-8 locale:
The locales will be updated next time Template:Filename is sourced. To source it, 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 Template:Filename. However, this method is now deprecated. To enable this behavior, simply add the following to Template:Filename:
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 Template:Filename:
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
Gnome-terminal doesn't support UTF-8
Append these two lines to the Template:Filename file:
Reboot your system, and gnome-terminal should work correctly.