This wiki page is a work in progress. There is precious little documentation covering locales, either in books or on the web. It will take either a) a bit of time, or b) a professional, to make this page a good reference. Three question marks are a placeholder for information that is lacking.
Locales customize programs to your language and country. When you installed Ubuntu, you answered some simple questions such as specifying your country and language. Ubuntu used the answers to those questions, in part, to choose a suitable locale for your installation.
The basic functionality is provided by the locales package, which is installed by default. Actual locales are installed separately via the language-pack-* packages.
Most users want a single locale to be used for all aspects of their session. In this case, the GUI provided by System Settings -> Language Support does the right thing.
This page is about more fine-grained, non-GUI customization.
List installed locales
The command 'locale -a' will show which locales are available on your system:
$ locale -a C # fall-back, ASCII encoding, same as POSIX de_DE.utf8 # German language, Germany, UTF-8 encoding de_CH.utf8 # German language, Switzerland, UTF-8 encoding fr_CH.utf8 # French language, Switzerland, UTF-8 encoding fr_CA.utf8 # French language, Canada, UTF-8 encoding en_US.utf8 # English language, USA, UTF-8 encoding POSIX # fall-back, ASCII encoding, same as C
List current settings
A piece of software is expected to utilize one or more of the installed locales, depending on a couple of environment variables, each covering a different aspect (a locale category). To list those variables and see their current value, use:
In the output of the above query, you will see entries for:
- Provides default value for LC_* variables that have not been explicitly set.
- How addresses are formatted (country first or last, where zip code goes etc.).
- Overrides individual LC_* settings: if LC_ALL is set, none of the below have any effect.
- How strings (file names...) are alphabetically sorted. Using the "C" or "POSIX" locale here results in a strcmp()-like sort order, which may be preferable to language-specific locales.
- How characters are classified as letters, numbers etc. This determines things like how characters are converted between upper and lower case.
- Metadata about the locale information.
- What units of measurement are used (feet, meters, pounds, kilos etc.).
- What language should be used for system messages.
- What currency you use, its name, and its symbol.
- How names are represented (surname first or last, etc.).
- How you format your numbers. For example, in many countries a period (.) is used as a decimal separator, while others use a comma (,).
- Paper sizes: 11 x 17 inches, A4, etc.
- Determines how responses (such as Yes and No) appear in the local language
- What your telephone numbers look like.
- How your time and date are formatted. Use for example "en_DK.UTF-8" to get a 24-hour-clock in some programs.
Changing settings temporarily
Any environment variable may be set on the command line for the current process:
$ date Sat May 14 15:59:12 CEST 2011 $ LC_TIME=zh_CN.UTF-8 $ date 2011年 05月 14日 星期六 16:00:13 CEST 2011
Changing settings permanently
If you want more fine-grained control, you may manually change your system's locale entries by modifying the file /etc/default/locale (or the user-specific $HOME/.pam_environment, which can be set by gnome-language-selector as well).
For example on a German system, to prevent system messages from being translated, you may use:
Note: changes take effect only after a fresh login.
Older releases, at least before Lucid (when did this change?), required modifying the file /etc/environment.
As an alternative to editing these files by hand update-locale may be used (this applies to older releases as well, at least before Raring):
$ update-locale LANG=de_DE.UTF-8 LC_MESSAGES=POSIX
If none of the above worked for you there is an option to change the actual definition of a locale. You need to edit a file with your locale, for instance:
$ sudo nano /usr/share/i18n/locales/ru_RU and change the definition that you need.
and then recompile locale definition files by:
$ sudo locale-gen
Read the man page for more information.
Installing a language-pack usually implies the creation of a file under /var/lib/locales/supported.d, named by language code (i.e. 'fr' for French), listing all locales that shall be generated.
Generation of locales is then automatically triggered as part of the installation process.
In order to trigger generation manually, do:
$ sudo locale-gen Generating locales... de_CH.UTF-8... done de_DE.UTF-8... done en_US.UTF-8... up-to-date Generation complete.
You may also generate new locales by issuing:
$ sudo locale-gen fr_FR.UTF-8 Generating locales... fr_FR.UTF-8... done Generation complete.
This will also append the specified locale to /var/lib/locales/supported.d/local for future regenerations.
The gnome display manager (GDM) has its own settings, including GDM_LANG for example, and is known to change locale settings when running /etc/gdm/Xsession. You may want to examine GDM's cache (/var/cache/gdm/$USER/dmrc) and restart GDM.
Interesting man pages (note that the section number is important):
Documentation about the common character sets: