Reconfigure locale

Changing the language of a Linux installation can be done by the following commands.

The settings itself are stored in the file /etc/default/locale:

  1. LANG=de_DE.UTF-8

It can contain more settings if different languages should be used for different aspects of the systems.

The current active locale can be displayed by the following command:

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

All available locales can be displayed by the following command:

  1. root@machine:~# locale -a
  2. C
  3. C.UTF-8
  4. de_DE.utf8
  5. en_US.utf8
  6. POSIX

You can also get some extra information adding the -v (verbose) parameter:

  1. root@machine:~# locale -a -v
  2. locale: de_DE.utf8 archive: /usr/lib/locale/locale-archive
  3. -------------------------------------------------------------------------------
  4. title | German locale for Germany
  5. source | Free Software Foundation, Inc.
  6. address | http://www.gnu.org/software/libc/
  7. email | bug-glibc-locales@gnu.org
  8. language | German
  9. territory | Germany
  10. revision | 1.0
  11. date | 2000-06-24
  12. codeset | UTF-8
  13.  
  14. locale: en_US.utf8 archive: /usr/lib/locale/locale-archive
  15. -------------------------------------------------------------------------------
  16. title | English locale for the USA
  17. source | Free Software Foundation, Inc.
  18. address | http://www.gnu.org/software/libc/
  19. email | bug-glibc-locales@gnu.org
  20. language | American English
  21. territory | United States
  22. revision | 1.0
  23. date | 2000-06-24
  24. codeset | UTF-8
  25.  
  26. locale: C.UTF-8 directory: /usr/lib/locale/C.UTF-8
  27. -------------------------------------------------------------------------------
  28. title | C locale
  29. email | aurel32@debian.org
  30. language | C
  31. revision | 1.6
  32. date | 2016-08-08
  33. codeset | UTF-8

The locale can be changed by the following command (changes the locale to German):

  1. root@machine:~# update-locale LANG=de_DE.UTF-8

If you get an error message, maybe the locale you defined doesn't exist yet. So you have to create it by the following command:

  1. root@machine:~# locale-gen --purge de_DE.UTF-8

The --purge parameter will remove existing locales before processing.

Another way to create locales is the following command - which will show a dialog for doing so:

  1. root@machine:~# dpkg-reconfigure locales

Locales are cached in the file /usr/lib/locale/locale-archive. This cache can be modified by the following commands.

All locales in the archive can be listed by:

  1. root@machine:~# localedef --list
  2. de_DE.utf8
  3. en_US.utf8

A locale can be deleted from the archive by (deletes the German locale, but must be one of the locales printed by the --list parameter):

  1. root@machine:~# localedef --delete-from-archive de_DE.utf8

Sources