Skip to main content

On waste from /usr/share/locale

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.

–Mike