February 8, 2007 · General · Email This Post

Sponsored Link
For those of you who are used to running "dpkg-reconfigure locales" on Debian to select and generate locales you may be a bit disappointed at the seemingly broken way it is done under Ubuntu.

When I say broken "sudo dpkg-reconfigure locales" does not yield an interface that allows you to select and deselect locales. It simply generates the locales mentioned in "/var/lib/locales/supported.d/local" file. Therefore if you want to generate a bunch of locales you will need to add them to this file and re-run "dpkg-reconfigure locales".

NOTE: One locale per line.

For a list of valid locales you can search through "/usr/share/i18n/SUPPORTED".

This tip from here

Incoming search terms:

Related posts

10 Comments to “How to select and generate locales on Ubuntu”

  1. Ghislain LEVEQUE says:

    Great ! I was looking for that ! Thank you

    [Reply]

  2. ‘sudo’ should be used with the dpkg-reconfigure command (enabling the command to be issued as the super user).

    That kind of information should not be left out or assumed when you’re giving instructions on how to manipulate the base functioning of a system.

    [Reply]

  3. admin says:

    @greg

    Thanks for your comment.I have updated the article.

    [Reply]

  4. emerg says:

    thanks, it worked, unlike other comments on the net

    to Greg Rundlett:
    mentioning the sudo notice is kinda redundant — if the user is unfamiliar with absolutely basic unix/linux/ubuntu concepts, what on earth he tries to do with locales?

    [Reply]

  5. Stephane says:

    To add a locale:

    sudo locale-gen [locale-name...]

    Such as:

    sudo locale-gen fr_FR.UTF-8

    That will add the locale to /var/lib/locales/supported.d/local and generates the locale data for that locale.

    That’s documented in locale-gen’s man page.

    To remove a locale, you still need to edit the supported.d files by hand though.

    [Reply]

  6. PomCompot says:

    In fact, in Jaunty, /var/lib/locales/supported.d/local is not enough, you need to edit the other files in that folder: /var/lib/locales/supported.d/en for instance.

    [Reply]

  7. Peter says:

    There is a package for Ubuntu that can take care of removing locales: localepurge

    You can run(!) it issueing:
    $ sudo apt-get install localepurge

    For more information see https://help.ubuntu.com/community/LocaleConf

    [Reply]

  8. Peter says:

    There is a package for Ubuntu that can take care of removing locales and locale related files (e.g. man pages): localepurge

    You can install/run it issueing:
    sudo apt-get install localepurge

    For more information see
    http://pwet.fr/man/linux/administration_systeme/localepurge
    https://help.ubuntu.com/community/LocaleConf

    What also should help to understand which files are involved is running locale in verbode mode:
    locale -a -v

    It shows that all generate locales are located in /usr/lib/locale/, which you may remove if unneeded.

    If error messages are displayed when issuing the locale command, e.g.

    locale: Cannot set LC_ALL to default locale: No such file or directory

    … make sure the file /etc/default/locales exists and has content similar to this:

    LANG=”en_US”
    LANGUAGE=”en_US:en”

    [Reply]

  9. Peter says:

    There is a package for Ubuntu that can take care of removing locales and locale related files (e.g. man pages): localepurge

    You can install/run it issueing:

    sudo apt-get install localepurge

    For more information see
    http://pwet.fr/man/linux/administration_systeme/localepurge
    https://help.ubuntu.com/community/LocaleConf

    What also should help to understand which files are involved is running locale in verbode mode:

    locale -a -v

    It shows that all generate locales are located in /usr/lib/locale/, which you may remove if unneeded.

    If error messages are displayed when issuing the locale command, e.g.

    locale: Cannot set LC_ALL to default locale: No such file or directory

    … make sure the file /etc/default/locales exists and has content similar to this:

    LANG=”en_US”
    LANGUAGE=”en_US:en”

    Essentially, what I did to clean up my locales is:

    1. Removed all unneeded locales from /var/lib/locales/supported.d/en
    2. Create /etc/default/locales (with content as above)
    3. Delete all generated locale data: rm -rfv /usr/lib/locale/*
    4. Re-generate new locales: locale-gen

    Good luck!

    [Reply]

  10. Viðarr says:

    The file named “local” in the aforementioned folder contained en_US.UTF-8 for me. But I noticed that it was also re-generating the locales for all other English configurations, so I *removed* the file named “en” and ran “dpkg-reconfigure locales” and all others are gone now.

    I had not noticed that before, but I had thought that only en_US.UTF-8 was configured.

    This was on 10.10.

    [Reply]

Leave a Reply