On waste from /usr/share/locale 2011-11-28

I recently  noticed 200MB waste from /usr/share/locale from languages that I never configured. So I turned to the gentoo-user mailing list and got

  • a detailed reply by Mike Edenfield (quoted below)
  • a hint on app-admin/localepurge by walt/w41ter

As I liked the explanation by Mike, I asked for permission to quote it as CC-BY-SA/3.0 here, which he confirmed:

Different packages include different levels of support for filtering their installed localization messages, typically one of “install everything”, “install what’s requested”, or “whats a locale?”

The reason you mostly have files under LC_MESSAGES is because that’s 99% of what is needed to localize a package. The files in there are string resource packages, translations of the strings used by the program, which are picked up by the localization library (gettext) automatically based on your locale settings. (coreutils installs file into LC_TIME for locales with date/time formatting requirements; I don’t think I’ve ever seen any other locale files.)

The standard way to inform a package which languages you want is to set your LINGUAS variable in /etc/make.conf to the locale name(s) you want installed (without the charset specifier). LINGUAS works like any other portage expansion variables: for those packages that support it, you get a set of USE-flag-like language keywords set on build. (LINGUAS is the well-known environment variable used by most autotools-based packages to select languages, but portage provides support above and beyond that.)

Unfortunately, proper locale support is spotty — mostly due to upstream maintainers being too lazy to properly add it to their builds. Instead, the package will install every message file it has available all the time.

You can safely delete any folders from /usr/share/locale for locales that you don’t have installed, since the normal locale support in glibc will never ask for them. But they’ll just get put back next time you upgrade the package.


Zenkibou November 28th, 2011

Maybe those files should just be filtered, something like INSTALL_MASK but for languages?
Why let the packages install anything they want, we can filter those since it’s always the same hierarchy.

yoshi314 November 29th, 2011

there is also localepurge to clean up unnecessary locales, and from much more places than /usr/share/locale.

you can simply add it as post-install hook, too (debian has such a hook by default after configuring localepurge).

Sylvain November 30th, 2011

Thanks for this… I never gave a thought to this “locales leaking” issue, but it makes perfect sense. 170 MB freed on my root filesystem thanks to your advice.

Leave a Reply

You must be logged in to post a comment.