Configure Locales in Ubuntu

Configure Locales in Ubuntu

Locales (language settings) can be configured for Ubuntu from the command line. This guide is applicable to Ubuntu 11.10 and provides steps for displaying current settings, available locales, and adjusting locales as needed.

Displaying the Current Settings

You can check the current locale settings using the locale command:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
$ locale
LANG=en_US.UTF-8
LANGUAGE=
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=

This output displays the current locale settings for various aspects of the system.

Displaying the Available Locales

To see a list of available locales, use the locale -a command:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
$ locale -a
C
C.UTF-8
de_AT.utf8
de_BE.utf8
de_CH.utf8
de_DE.utf8
de_LI.utf8
de_LU.utf8
en_AG
en_AG.utf8
...
POSIX

If a required locale doesn’t appear in the list, you may need to install it. For example, to generate the fr_FR.UTF-8 locale, you can use the locale-gen command:

1
2
3
4
# locale-gen fr_FR.UTF-8
Generating locales...
fr_FR.UTF-8... done
Generation complete.

Adjusting Locales

Locale settings are stored in the /etc/default/locale file. You can view the current settings using the cat command:

1
2
$ cat /etc/default/locale 
LANG=en_US.UTF-8

To manually adjust these settings, you can edit the /etc/default/locale file. Alternatively, you can use the update-locale tool. For example, to set the system’s language to German (de_DE.UTF-8), you can use:

1
# update-locale LANG=de_DE.UTF-8

This tool is particularly useful when you want the system to operate in one language (e.g., German) but display error and system messages in another language (e.g., English). To achieve this, you can modify /etc/default/locale or /etc/environment like this:

1
2
3
4
5
6
7
8
9
/etc/default/locale:
LANG=de_DE.UTF-8
LC_MESSAGES=POSIX

/etc/environment:
LANGUAGE=en_US.UTF-8
LC_ALL=en_US.UTF-8
LANG=en_US.UTF-8
LC_TYPE=en_US.UTF-8

By configuring locales in Ubuntu, you can customize the language settings to suit your preferences and requirements.

0%