How to remove unnecessary locales?

61,216

Solution 1

First type the locale command to print-out your current locale configuration. Also you can use locale -a to display a list of all available locales.

Cleaning up unused locales

Install localepurge to remove any unwanted languages, while choosing the ones you want to keep. Note that this method will not change the locales settings on your system. It will just purge the locales you have not selected. Use at your own risk.

$ sudo apt-get install localepurge

After that, you could reboot or try to run . /etc/default/locale.

To reconfigure this, simply enter the following in terminal:

$ sudo dpkg-reconfigure localepurge

Another way answered here is to sudo locale-gen --purge <locales YOU WANT TO KEEP>

Reference

Solution 2

Unless you have a need to switch to various locales all the time, you can uninstall the unused locales and free up some amount of the storage space in your system.

Install Localepurge via the terminal:

sudo apt-get install localepurge

Once the installation is done, it will remove all locale files from your system that you have no need for.

Solution 3

Use apt install localepurge, but this only stops new packages from installing locales files. "This option will become active for packages unpacked after localepurge has been (re)configured. Packages installed or upgraded together with localepurge may (or may not) be subject to the previous configuration of localepurge."

Then rm -rI /usr/share/locale/!(en).

Then possibly reinstall packages if they have locales files in their own directories.

Careful, apparently rm /dir !() removes files in your current dir (pwd).

How to delete all files except one named file from a specific folder

https://askubuntu.com/a/624445/795299 (relevant top answer from above link)

Use apt install --reinstall locales if you accidentally delete a dir.

Share:
61,216

Related videos on Youtube

user289256
Author by

user289256

Updated on September 18, 2022

Comments

  • user289256
    user289256 almost 2 years

    I noticed I have several unneeded locales installed, for example, firefox-locale-. I only need one locale.

    How to remove all the rest?

  • sevo
    sevo almost 7 years
    Quoting localepurge man page: "Please note, that this tool is a hack which is not integrated with Debian's package management system [...]"
  • kristopolous
    kristopolous almost 6 years
    none of these things seem to actually remove any files. /usr/share/man still has all the languages. /usr/share/locale still has all the directories.
  • Markus Bawidamann
    Markus Bawidamann over 3 years
    This might break your system, localpurge on Debian is not supported by the package manager. This is a pretty ugly hack, sadly. I wish it was otherwise.
  • alchemy
    alchemy over 2 years
    localepurge only "prevents future packages from generate unwanted locales". see my answer.
  • alchemy
    alchemy over 2 years
    localepurge only "prevents future packages from generate unwanted locales". see my answer.