How to remove unnecessary locale files

I recently checked the /usr/share/locale/ directory on my EOS installation. Its size is in excess of 700 MB. There are basically two options listed in the various threads to reclaim the space occupied by various locale.

  1. Use the AUR package localepurge. This appears to be Debian port into Arch.
  2. Use the command yay -S localepurge as given in this thread.

How can I reclaim space from the various different locales? Is there a mechanism to check how much size each locale is using? Is there any alternative apart from localepurge or using yay -S localepurge

These are the same option.
yay is an AUR helper .. the second example is just a more explicitly illustrated step to get get localepurge from the AUR.

Maybe something like

du -h /usr/share/locale/*

You could remove what you dont want and add it to NoExtract in pacman.conf

If you remove most everything in that folder, you will see, most probably, the following when you update your system or perhaps even when you install a package. I find this much more disturbing than a few hundred MB space occupied on the disk.

checking available disk space...
warning: could not get file information for usr/share/locale/af/
warning: could not get file information for usr/share/locale/af/LC_MESSAGES/
warning: could not get file information for usr/share/locale/af/LC_MESSAGES/coreutils.mo
warning: could not get file information for usr/share/locale/af/LC_TIME/
warning: could not get file information for usr/share/locale/af/LC_TIME/coreutils.mo
warning: could not get file information for usr/share/locale/be/
warning: could not get file information for usr/share/locale/be/LC_MESSAGES/
warning: could not get file information for usr/share/locale/be/LC_MESSAGES/coreutils.mo
warning: could not get file information for usr/share/locale/be/LC_TIME/
warning: could not get file information for usr/share/locale/be/LC_TIME/coreutils.mo
warning: could not get file information for usr/share/locale/bg/
warning: could not get file information for usr/share/locale/bg/LC_MESSAGES/
warning: could not get file information for usr/share/locale/bg/LC_MESSAGES/coreutils.mo
warning: could not get file information for usr/share/locale/bg/LC_TIME/
warning: could not get file information for usr/share/locale/bg/LC_TIME/coreutils.mo
warning: could not get file information for usr/share/locale/ca/
warning: could not get file information for usr/share/locale/ca/LC_MESSAGES/
warning: could not get file information for usr/share/locale/ca/LC_MESSAGES/coreutils.mo
warning: could not get file information for usr/share/locale/ca/LC_TIME/
warning: could not get file information for usr/share/locale/ca/LC_TIME/coreutils.mo
warning: could not get file information for usr/share/locale/cs/
warning: could not get file information for usr/share/locale/cs/LC_MESSAGES/
warning: could not get file information for usr/share/locale/cs/LC_MESSAGES/coreutils.mo
warning: could not get file information for usr/share/locale/cs/LC_TIME/
warning: could not get file information for usr/share/locale/cs/LC_TIME/coreutils.mo
warning: could not get file information for usr/share/locale/da/
warning: could not get file information for usr/share/locale/da/LC_MESSAGES/
warning: could not get file information for usr/share/locale/da/LC_MESSAGES/coreutils.mo
warning: could not get file information for usr/share/locale/da/LC_TIME/
warning: could not get file information for usr/share/locale/da/LC_TIME/coreutils.mo
warning: could not get file information for usr/share/locale/de/
warning: could not get file information for usr/share/locale/de/LC_MESSAGES/
warning: could not get file information for usr/share/locale/de/LC_MESSAGES/coreutils.mo
warning: could not get file information for usr/share/locale/de/LC_TIME/
warning: could not get file information for usr/share/locale/de/LC_TIME/coreutils.mo
warning: could not get file information for usr/share/locale/el/
warning: could not get file information for usr/share/locale/el/LC_MESSAGES/
warning: could not get file information for usr/share/locale/el/LC_MESSAGES/coreutils.mo
warning: could not get file information for usr/share/locale/el/LC_TIME/
warning: could not get file information for usr/share/locale/el/LC_TIME/coreutils.mo
warning: could not get file information for usr/share/locale/eo/
warning: could not get file information for usr/share/locale/eo/LC_MESSAGES/
warning: could not get file information for usr/share/locale/eo/LC_MESSAGES/coreutils.mo
warning: could not get file information for usr/share/locale/eo/LC_TIME/
warning: could not get file information for usr/share/locale/eo/LC_TIME/coreutils.mo
warning: could not get file information for usr/share/locale/es/
warning: could not get file information for usr/share/locale/es/LC_MESSAGES/
warning: could not get file information for usr/share/locale/es/LC_MESSAGES/coreutils.mo
warning: could not get file information for usr/share/locale/es/LC_TIME/
warning: could not get file information for usr/share/locale/es/LC_TIME/coreutils.mo
warning: could not get file information for usr/share/locale/et/
warning: could not get file information for usr/share/locale/et/LC_MESSAGES/
warning: could not get file information for usr/share/locale/et/LC_MESSAGES/coreutils.mo
warning: could not get file information for usr/share/locale/et/LC_TIME/
warning: could not get file information for usr/share/locale/et/LC_TIME/coreutils.mo
warning: could not get file information for usr/share/locale/eu/
warning: could not get file information for usr/share/locale/eu/LC_MESSAGES/
warning: could not get file information for usr/share/locale/eu/LC_MESSAGES/coreutils.mo
warning: could not get file information for usr/share/locale/eu/LC_TIME/
warning: could not get file information for usr/share/locale/eu/LC_TIME/coreutils.mo
warning: could not get file information for usr/share/locale/fi/
warning: could not get file information for usr/share/locale/fi/LC_MESSAGES/
warning: could not get file information for usr/share/locale/fi/LC_MESSAGES/coreutils.mo
warning: could not get file information for usr/share/locale/fi/LC_TIME/
warning: could not get file information for usr/share/locale/fi/LC_TIME/coreutils.mo
warning: could not get file information for usr/share/locale/fr/
warning: could not get file information for usr/share/locale/fr/LC_MESSAGES/
warning: could not get file information for usr/share/locale/fr/LC_MESSAGES/coreutils.mo
warning: could not get file information for usr/share/locale/fr/LC_TIME/
warning: could not get file information for usr/share/locale/fr/LC_TIME/coreutils.mo
warning: could not get file information for usr/share/locale/ga/
warning: could not get file information for usr/share/locale/ga/LC_MESSAGES/
warning: could not get file information for usr/share/locale/ga/LC_MESSAGES/coreutils.mo
warning: could not get file information for usr/share/locale/ga/LC_TIME/
warning: could not get file information for usr/share/locale/ga/LC_TIME/coreutils.mo
warning: could not get file information for usr/share/locale/gl/
warning: could not get file information for usr/share/locale/gl/LC_MESSAGES/
warning: could not get file information for usr/share/locale/gl/LC_MESSAGES/coreutils.mo
warning: could not get file information for usr/share/locale/gl/LC_TIME/
warning: could not get file information for usr/share/locale/gl/LC_TIME/coreutils.mo
warning: could not get file information for usr/share/locale/hr/
warning: could not get file information for usr/share/locale/hr/LC_MESSAGES/
warning: could not get file information for usr/share/locale/hr/LC_MESSAGES/coreutils.mo
warning: could not get file information for usr/share/locale/hr/LC_TIME/
warning: could not get file information for usr/share/locale/hr/LC_TIME/coreutils.mo
warning: could not get file information for usr/share/locale/hu/
warning: could not get file information for usr/share/locale/hu/LC_MESSAGES/
warning: could not get file information for usr/share/locale/hu/LC_MESSAGES/coreutils.mo
warning: could not get file information for usr/share/locale/hu/LC_TIME/
warning: could not get file information for usr/share/locale/hu/LC_TIME/coreutils.mo
warning: could not get file information for usr/share/locale/ia/
warning: could not get file information for usr/share/locale/ia/LC_MESSAGES/
warning: could not get file information for usr/share/locale/ia/LC_MESSAGES/coreutils.mo
warning: could not get file information for usr/share/locale/ia/LC_TIME/
warning: could not get file information for usr/share/locale/ia/LC_TIME/coreutils.mo
warning: could not get file information for usr/share/locale/id/
warning: could not get file information for usr/share/locale/id/LC_MESSAGES/
warning: could not get file information for usr/share/locale/id/LC_MESSAGES/coreutils.mo
warning: could not get file information for usr/share/locale/id/LC_TIME/
warning: could not get file information for usr/share/locale/id/LC_TIME/coreutils.mo
warning: could not get file information for usr/share/locale/it/
warning: could not get file information for usr/share/locale/it/LC_MESSAGES/
warning: could not get file information for usr/share/locale/it/LC_MESSAGES/coreutils.mo
warning: could not get file information for usr/share/locale/it/LC_TIME/
warning: could not get file information for usr/share/locale/it/LC_TIME/coreutils.mo
warning: could not get file information for usr/share/locale/ja/
warning: could not get file information for usr/share/locale/ja/LC_MESSAGES/
warning: could not get file information for usr/share/locale/ja/LC_MESSAGES/coreutils.mo
warning: could not get file information for usr/share/locale/ja/LC_TIME/
warning: could not get file information for usr/share/locale/ja/LC_TIME/coreutils.mo
warning: could not get file information for usr/share/locale/ka/
warning: could not get file information for usr/share/locale/ka/LC_MESSAGES/
warning: could not get file information for usr/share/locale/ka/LC_MESSAGES/coreutils.mo
warning: could not get file information for usr/share/locale/ka/LC_TIME/
warning: could not get file information for usr/share/locale/ka/LC_TIME/coreutils.mo
warning: could not get file information for usr/share/locale/kk/
warning: could not get file information for usr/share/locale/kk/LC_MESSAGES/
warning: could not get file information for usr/share/locale/kk/LC_MESSAGES/coreutils.mo
warning: could not get file information for usr/share/locale/kk/LC_TIME/
warning: could not get file information for usr/share/locale/kk/LC_TIME/coreutils.mo
warning: could not get file information for usr/share/locale/ko/
warning: could not get file information for usr/share/locale/ko/LC_MESSAGES/
warning: could not get file information for usr/share/locale/ko/LC_MESSAGES/coreutils.mo
warning: could not get file information for usr/share/locale/ko/LC_TIME/
warning: could not get file information for usr/share/locale/ko/LC_TIME/coreutils.mo
warning: could not get file information for usr/share/locale/lg/
warning: could not get file information for usr/share/locale/lg/LC_MESSAGES/
warning: could not get file information for usr/share/locale/lg/LC_MESSAGES/coreutils.mo
warning: could not get file information for usr/share/locale/lg/LC_TIME/
warning: could not get file information for usr/share/locale/lg/LC_TIME/coreutils.mo
warning: could not get file information for usr/share/locale/lt/
warning: could not get file information for usr/share/locale/lt/LC_MESSAGES/
warning: could not get file information for usr/share/locale/lt/LC_MESSAGES/coreutils.mo
warning: could not get file information for usr/share/locale/lt/LC_TIME/
warning: could not get file information for usr/share/locale/lt/LC_TIME/coreutils.mo
warning: could not get file information for usr/share/locale/ms/
warning: could not get file information for usr/share/locale/ms/LC_MESSAGES/
warning: could not get file information for usr/share/locale/ms/LC_MESSAGES/coreutils.mo
warning: could not get file information for usr/share/locale/ms/LC_TIME/
warning: could not get file information for usr/share/locale/ms/LC_TIME/coreutils.mo
warning: could not get file information for usr/share/locale/nb/
warning: could not get file information for usr/share/locale/nb/LC_MESSAGES/
warning: could not get file information for usr/share/locale/nb/LC_MESSAGES/coreutils.mo
warning: could not get file information for usr/share/locale/nb/LC_TIME/
warning: could not get file information for usr/share/locale/nb/LC_TIME/coreutils.mo
warning: could not get file information for usr/share/locale/nl/
warning: could not get file information for usr/share/locale/nl/LC_MESSAGES/
warning: could not get file information for usr/share/locale/nl/LC_MESSAGES/coreutils.mo
warning: could not get file information for usr/share/locale/nl/LC_TIME/
warning: could not get file information for usr/share/locale/nl/LC_TIME/coreutils.mo
warning: could not get file information for usr/share/locale/pl/
warning: could not get file information for usr/share/locale/pl/LC_MESSAGES/
warning: could not get file information for usr/share/locale/pl/LC_MESSAGES/coreutils.mo
warning: could not get file information for usr/share/locale/pl/LC_TIME/
warning: could not get file information for usr/share/locale/pl/LC_TIME/coreutils.mo
warning: could not get file information for usr/share/locale/pt/
warning: could not get file information for usr/share/locale/pt/LC_MESSAGES/
warning: could not get file information for usr/share/locale/pt/LC_MESSAGES/coreutils.mo
warning: could not get file information for usr/share/locale/pt/LC_TIME/
warning: could not get file information for usr/share/locale/pt/LC_TIME/coreutils.mo
warning: could not get file information for usr/share/locale/pt_BR/
warning: could not get file information for usr/share/locale/pt_BR/LC_MESSAGES/
warning: could not get file information for usr/share/locale/pt_BR/LC_MESSAGES/coreutils.mo
warning: could not get file information for usr/share/locale/pt_BR/LC_TIME/
warning: could not get file information for usr/share/locale/pt_BR/LC_TIME/coreutils.mo
warning: could not get file information for usr/share/locale/ro/
warning: could not get file information for usr/share/locale/ro/LC_MESSAGES/
warning: could not get file information for usr/share/locale/ro/LC_MESSAGES/coreutils.mo
warning: could not get file information for usr/share/locale/ro/LC_TIME/
warning: could not get file information for usr/share/locale/ro/LC_TIME/coreutils.mo
warning: could not get file information for usr/share/locale/ru/
warning: could not get file information for usr/share/locale/ru/LC_MESSAGES/
warning: could not get file information for usr/share/locale/ru/LC_MESSAGES/coreutils.mo
warning: could not get file information for usr/share/locale/ru/LC_TIME/
warning: could not get file information for usr/share/locale/ru/LC_TIME/coreutils.mo
warning: could not get file information for usr/share/locale/sk/
warning: could not get file information for usr/share/locale/sk/LC_MESSAGES/
warning: could not get file information for usr/share/locale/sk/LC_MESSAGES/coreutils.mo
warning: could not get file information for usr/share/locale/sk/LC_TIME/
warning: could not get file information for usr/share/locale/sk/LC_TIME/coreutils.mo
warning: could not get file information for usr/share/locale/sl/
warning: could not get file information for usr/share/locale/sl/LC_MESSAGES/
warning: could not get file information for usr/share/locale/sl/LC_MESSAGES/coreutils.mo
warning: could not get file information for usr/share/locale/sl/LC_TIME/
warning: could not get file information for usr/share/locale/sl/LC_TIME/coreutils.mo
warning: could not get file information for usr/share/locale/sr/
warning: could not get file information for usr/share/locale/sr/LC_MESSAGES/
warning: could not get file information for usr/share/locale/sr/LC_MESSAGES/coreutils.mo
warning: could not get file information for usr/share/locale/sr/LC_TIME/
warning: could not get file information for usr/share/locale/sr/LC_TIME/coreutils.mo
warning: could not get file information for usr/share/locale/sv/
warning: could not get file information for usr/share/locale/sv/LC_MESSAGES/
warning: could not get file information for usr/share/locale/sv/LC_MESSAGES/coreutils.mo
warning: could not get file information for usr/share/locale/sv/LC_TIME/
warning: could not get file information for usr/share/locale/sv/LC_TIME/coreutils.mo
warning: could not get file information for usr/share/locale/ta/
warning: could not get file information for usr/share/locale/ta/LC_MESSAGES/
warning: could not get file information for usr/share/locale/ta/LC_MESSAGES/coreutils.mo
warning: could not get file information for usr/share/locale/ta/LC_TIME/
warning: could not get file information for usr/share/locale/ta/LC_TIME/coreutils.mo
warning: could not get file information for usr/share/locale/tr/
warning: could not get file information for usr/share/locale/tr/LC_MESSAGES/
warning: could not get file information for usr/share/locale/tr/LC_MESSAGES/coreutils.mo
warning: could not get file information for usr/share/locale/tr/LC_TIME/
warning: could not get file information for usr/share/locale/tr/LC_TIME/coreutils.mo
warning: could not get file information for usr/share/locale/uk/
warning: could not get file information for usr/share/locale/uk/LC_MESSAGES/
warning: could not get file information for usr/share/locale/uk/LC_MESSAGES/coreutils.mo
warning: could not get file information for usr/share/locale/uk/LC_TIME/
warning: could not get file information for usr/share/locale/uk/LC_TIME/coreutils.mo
warning: could not get file information for usr/share/locale/vi/
warning: could not get file information for usr/share/locale/vi/LC_MESSAGES/
warning: could not get file information for usr/share/locale/vi/LC_MESSAGES/coreutils.mo
warning: could not get file information for usr/share/locale/vi/LC_TIME/
warning: could not get file information for usr/share/locale/vi/LC_TIME/coreutils.mo
warning: could not get file information for usr/share/locale/zh_CN/
warning: could not get file information for usr/share/locale/zh_CN/LC_MESSAGES/
warning: could not get file information for usr/share/locale/zh_CN/LC_MESSAGES/coreutils.mo
warning: could not get file information for usr/share/locale/zh_CN/LC_TIME/
warning: could not get file information for usr/share/locale/zh_CN/LC_TIME/coreutils.mo
warning: could not get file information for usr/share/locale/zh_TW/
warning: could not get file information for usr/share/locale/zh_TW/LC_MESSAGES/
warning: could not get file information for usr/share/locale/zh_TW/LC_MESSAGES/coreutils.mo
warning: could not get file information for usr/share/locale/zh_TW/LC_TIME/
warning: could not get file information for usr/share/locale/zh_TW/LC_TIME/coreutils.mo

Install ncdu.
ncdu /usr/share/locale

Not if you

Meaning something like

/etc/pacman.conf

[...]
NoExtract = usr/share/locale/* !usr/share/locale/en* !usr/share/locale/locale.alias
[...]

(replacing en above with your local language prefix)

3 Likes

Thanks! I appreciate it!

1 Like

So can AUR package localepurge be used safely on Arch based distros without any issue?

@cscs thanks for your responses on using NoExtract in pacman.conf

@cactux thanks for pointing out what would happen if I were to remove all the locales apart from my primary input language. It helps. I would have freaked out and would have dashed right into re-installation of EOS. That is something that I do not want to do.
I will have a look at ncdu.

Honestly, I haven’t used this program and it was the first time I heard it being mentioned, so I don’t know.

If I may give you my opinion, I think the whole thing would be too much work and hassle, removing the locales and then editing the pacman.conf file etc. for quite a little gain. A few hundred MB at max. I would just leave it and forget about it. But that’s me.

Are you really hurting for 700MB? Why bother?

You might start with cleaning old journal entries with:

sudo journalctl --vacuum-time=3days

or cleaning out the package cache with:

sudo paccache -rk1

If we are just throwing out cleaning things .. I might mention something for it;

2 Likes

Just had a look—very well done script! As long as this isn’t “yay-able” (in the AUR, maybe?), could you add its GitLab link into the head of the file?

Reason being: I tend to collect such stuff, but it could get outdated quickly, and it would be beneficial to be able to find it again & check for updates after a few months passed…

EDIT: Better even, put the link into its help, so we could Ctrl+Click it in a terminal and just jump there. :wink:

1 Like

The perfect tool for for this job is bleachbit. I know that it is considered a no-no for various reasons but the way it handles locales is clever. The directory structure is left intact and a single .mo file left in each locale MESSAGES folder. This avoids the issues mentioned above.
Out of interest in a test vm with Cinnamon and minimal software installed it cleaned out :-
Disk space recovered: 485.1MB
Files deleted: 16880
On my normal running system I have seen this around the 800MB and 29,000 file range.

1 Like

So I went with BleachBit to finally remove this. Hope there are alternatives too.

But the main question, how do we prevent such types of locales from being installed in the first place? Is there some setting that can be used?

I did describe a ‘setting’ ..

1 Like

Thanks @cscs. Will try that out. I might have missed this.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.