Browsed by
Tag: debian

Locales in Debian and Ubuntu

Locales in Debian and Ubuntu

Locales customize your system to languages and country specific settings.
On a single user system, you set up your locale at installation time and that’s it.
But if you need to support several different languages (e.g. an international ecommerce shop) you have to tweak your setup.

Command line tools, packages and configuration files

The locale command displays information about the current locale. The man page reveals more information:

When invoked without arguments, locale displays the current locale settings for each locale category (see locale(5)), based on the settings of the environment variables that control the locale (see locale(7)).

A locale is composed of several locale categories. When a program looks up locale dependent values, it does this according to the following environment variables:

$ locale

You can find more information about the variables and locales in general at and

Display a list of all available locales:

$ locale -a

Locales availabe for generation are configured in /etc/locales.gen
Just uncomment the locales you want to be available, then run the locale-gen command.

# This file lists locales that you wish to have built. You can find a list
# of valid supported locales at /usr/share/i18n/SUPPORTED, and you can add
# user defined locales to /usr/local/share/i18n/SUPPORTED. If you change
# this file, you need to rerun locale-gen.

# C.UTF-8 UTF-8
# aa_DJ ISO-8859-1
# aa_DJ.UTF-8 UTF-8
# aa_ER UTF-8


# de_CH.UTF-8 UTF-8
# de_DE ISO-8859-1
de_DE.UTF-8 UTF-8
# de_DE@euro ISO-8859-15
# de_IT ISO-8859-1
# de_IT.UTF-8 UTF-8
# de_LI.UTF-8 UTF-8


As an alternative, you could achieve the same result with:

$ sudo locale-gen fr_FR.UTF-8
Generating locales...
  fr_FR.UTF-8... done
Generation complete.

This will update the config file und generate the specified locale (fr_FR.UTF-8) in one step.

If you have a bunch of locales to generate the following shell snippet will help:

$ L="de_DE

$ for i in $L[*]; do
$  sudo sed -i s"/^# ${i}/${i}/g" locale.gen
$ done
$ sudo locale-gen
Generating locales (this might take a while)...
  de_DE.ISO-8859-1... done
  de_DE.UTF-8... done
  de_DE.ISO-8859-15@euro... done
  en_GB.ISO-8859-1... done
  en_GB.ISO-8859-15... done
  en_GB.UTF-8... done
  en_US.UTF-8... done
  es_ES.ISO-8859-1... done
  es_ES.UTF-8...^A done
  es_ES.ISO-8859-15@euro... done
  fr_FR.ISO-8859-1... done
  fr_FR.UTF-8... done
  fr_FR.ISO-8859-15@euro... done
  it_IT.ISO-8859-1... done
  it_IT.UTF-8... done
  it_IT.ISO-8859-15@euro... done
  nl_NL.ISO-8859-1... done
  nl_NL.UTF-8... done
  nl_NL.ISO-8859-15@euro... done
Generation complete.

The default locale is defined in /etc/default/locale


To change the default, you can edit the file or use update-locale like so

$ sudo update-locale LANG=de_DE.UTF-8

The advantage of using update-locale ist that some basic checks are performed to ensure that requested settings are valid.

Conclusion so far: with the tools described above you can cherry pick how locales are setup.

Language packs

Important: language-packs only apply to Ubuntu and not Debian

On Ubuntu you can also install language-packs.
There are a lot of them, seperated into base and updates packages, for example:

language-pack-en: translation updates for language English
Translation data updates for all supported packages for: English
language-pack-en-base provides the bulk of translation data and is updated
only seldom. This package provides frequent translation updates.

$ sudo aptitude search "^language-pack-*"
p   language-pack-af               - translation updates for language Afrikaans
p   language-pack-af-base          - translations for language Afrikaans
p   language-pack-am               - translation updates for language Amharic
p   language-pack-am-base          - translations for language Amharic
p   language-pack-an               - translation updates for language Aragonese
p   language-pack-an-base          - translations for language Aragonese
p   language-pack-ar               - translation updates for language Arabic
p   language-pack-ar-base          - translations for language Arabic
p   language-pack-as               - translation updates for language Assamese
p   language-pack-as-base          - translations for language Assamese
p   language-pack-ast              - translation updates for language Asturian
p   language-pack-ast-base         - translations for language Asturian
p   language-pack-az               - translation updates for language Azerbaijan
p   language-pack-az-base          - translations for language Azerbaijani
p   language-pack-be               - translation updates for language Belarusian
p   language-pack-be-base          - translations for language Belarusian
p   language-pack-bg               - translation updates for language Bulgarian
p   language-pack-bg-base          - translations for language Bulgarian
p   language-pack-bn               - translation updates for language Bengali
p   language-pack-bn-base          - translations for language Bengali
p   language-pack-br               - translation updates for language Breton
p   language-pack-br-base          - translations for language Breton


If you install a language-pack, additional configuration is installed in /var/lib/locales/supported.d
For English this will look like this:


en_HK.UTF-8 UTF-8
en_DK.UTF-8 UTF-8
en_IN UTF-8
en_IL UTF-8
en_ZM UTF-8
en_ZW.UTF-8 UTF-8
en_NZ.UTF-8 UTF-8
en_PH.UTF-8 UTF-8
en_NG UTF-8
en_US.UTF-8 UTF-8
en_GB.UTF-8 UTF-8
en_AU.UTF-8 UTF-8
en_SG.UTF-8 UTF-8
en_BW.UTF-8 UTF-8
en_AG UTF-8
en_ZA.UTF-8 UTF-8
en_CA.UTF-8 UTF-8
en_IE.UTF-8 UTF-8

Independently from the settings in /etc/locale.gen all the locales in /var/lib/locales/supported.d/en are beeing generated.

Create your own Debian mirror with debmirror

Create your own Debian mirror with debmirror

We will walk through these steps to get the local Debian mirror up and running:

  1. make sure you have enough space on your harddrive
  2. install debmirror, configure a cronjob to sync data
  3. make your mirror available to your clients (via apache or nfs)
  4. keep an eye on your cronjob – from time to time your script may have trouble to sync
  5. configure sources.list to use your local mirror

Read More Read More