Locales

Locales

About Locales

The "locale" is where you are (where your system is).

Specific "locales" (for example, French/Canada, Chinese/China and English/Great Britain) are first defined on a system and then used at runtime to display things in the way the local user expects.

Technically, a locale is identified by:

  • Language ('ll')
  • Country ('CC')
  • Encoding (always 'UTF-8' for Ubuntu)

Language and country values are defined in ISO standards. Files exist on your Ubuntu system containing this information:

  • Language codes:
    • /usr/share/xml/iso-codes/iso_639.xml
    • /usr/share/xml/iso-codes/iso_639_3.xml
  • Country codes:
    • /usr/share/xml/iso-codes/iso_3166.xml
    • /usr/share/xml/iso-codes/iso_3166_2.xml

Note: Typical users do not need to know any of this information or use any of these commands. This information is provided for those interested in a more system-oriented understanding.

Getting Started with Locales

Here are a few things you can do to get started understanding locales.

  • Display information about the current locale
  • Display all locales defined on your system
  • Generate new locales on your system
  • Change the command shell to a different locale

Showing the Current Locale

Use the locale command:

$ locale
LANG=en_US.utf8
LC_CTYPE="en_US.utf8"
LC_NUMERIC="en_US.utf8"
LC_TIME="en_US.utf8"
LC_COLLATE="en_US.utf8"
LC_MONETARY="en_US.utf8"
LC_MESSAGES="en_US.utf8"
LC_PAPER="en_US.utf8"
LC_NAME="en_US.utf8"
LC_ADDRESS="en_US.utf8"
LC_TELEPHONE="en_US.utf8"
LC_MEASUREMENT="en_US.utf8"
LC_IDENTIFICATION="en_US.utf8"
LC_ALL=

All of these values indicate English ("en") US ("US").

Are mixed locales possible? That is, can one set some aspects of a local to one value and some to another? Yes, theoretically, but not yet through the standard Ubuntu UI (the Language Support application).

Showing all Locales on the System

Use the locale -a command to show locales that are available for immediate use on

$ locale -a
C
de_AT.utf8
de_BE.utf8
de_CH.utf8
de_DE.utf8
de_LI.utf8
de_LU.utf8
en_AG
en_AU.utf8
en_BW.utf8
...

What is the "C" Locale?

It means "no locale" and is the default locale used when a more specific one is not available.

Generating a New Locale

Generate new locales on your system with sudo locale-gen ll_CC.UTF-8.

Generate the Spanish/Spain locale:

$ sudo locale-gen es_ES.UTF-8
Generating locales...
  es_ES.UTF-8... up-to-date
Generation complete.

Changing Command Shell Locale

Change your command shell to a new (already created) locale with LANGUAGE=<ll_CC> and LANG=<ll_CC>-UTF-8. After doing this, any processes you launch that check the locale will use the new one for translations. Thus, you can launch applications and view them in different locales.

Note To view correct translations for Ubuntu applications in Main and restricted, you must install the appropriate language packages. This is done automatically from the Language Support application.

$ LANGUAGE=es_ES
$ LANG=es_ES.UTF-8
$ locale
LANG=es_ES.UTF-8
LC_CTYPE="es_ES.UTF-8"
LC_NUMERIC="es_ES.UTF-8"
LC_TIME="es_ES.UTF-8"
LC_COLLATE="es_ES.UTF-8"
LC_MONETARY="es_ES.UTF-8"
LC_MESSAGES="es_ES.UTF-8"
LC_PAPER="es_ES.UTF-8"
LC_NAME="es_ES.UTF-8"
LC_ADDRESS="es_ES.UTF-8"
LC_TELEPHONE="es_ES.UTF-8"
LC_MEASUREMENT="es_ES.UTF-8"
LC_IDENTIFICATION="es_ES.UTF-8"
LC_ALL=

Next

Domains

UbuntuDevelopment/Internationalisation/InternationalizationPrimer/Locales (last edited 2011-07-27 22:46:23 by knitzsche)