Remove a locale in Ubuntu

Solution 1:

You can also reconfigure the locales package using dpkg-reconfigure locales.

Solution 2:

I think you can do this by editing /var/lib/locales/supported.d/local and removing that locale. Then run locale-gen to regenerate the compiled locales.


Solution 3:

Which locales are installed on my machine?

You can check which locales are generated and configured on your system using the locale command:

  • locale ... list the current locale configuration
  • locale -a ... lists all all locales that were generated on your system
  • locale -a -v ... list all locales and show useful additional information (such as directory names that contain the locale information data files)

The last command from above makes you see that all generated locales are located in /usr/lib/locale/, and you may remove any of them if unneeded. Each pack of locale information is a directory containing text files and other directories.

-

Supported locales

All locales that you want your system to support are listed in the text files in /var/lib/locales/supported.d/. These files have two columns, language tag and character map.

I want my system to know US-English only, so I have only one file there, called en, which contains just a single line:

en_US UTF-8

-

Error messages

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/locale exists and has proper content, such as:

LANG="en_US"
LANGUAGE="en_US:en"

-

Get rid of unneeded locale data - Step by step

Now we know all the necessary details to get started with cleaning up our system's locale information:

  1. Edit the locale file(s) in /var/lib/locales/supported.d/, and remove all unneeded locales (one locale per line)
  2. Create and edit /etc/default/locale (see above for an example)
  3. Delete all generated locale data: rm -rfv /usr/lib/locale/*
  4. Re-generate new locales: locale-gen

That's all! Reboot your machine to make your changes take effect. Then run one or more of the locale command examples from above to ensure yourself that the result is as expected.

-

Reference:

https://www.linuxquestions.org/questions/blog/bittner-195120/remove-unwanted-locales-on-ubuntu-debian-3281/