TIP Specifying only needed locales
From Gentoo Linux Wiki
| Terminals / Shells • Network • X Window System • Portage • System • Filesystems • Kernel • Other |
- This page is a candidate for deletion
- Reason given: Article is out of date. Official version available.
- If you disagree with its deletion, please explain why on its discussion page.
- If you intend to fix it, please remove this notice, but do not remove this notice from articles that you have created yourself.
- Make sure no other pages link here and check the page's history before deleting.
Contents |
[edit] Introduction
The locales a user can choose from are built by the glibc. Usually all available locales starting from aa_DJ (Afar locale for Djibouti) over en_US (English locale for the USA) to zu_ZA.utf8 (Zulu locale for South Africa) will be installed. Unless you're working at the UN and administer a central server for all member states, it is difficult to conceive why you would need a system where all of these locales are installed. This week's tip was written with all those of you in mind who'd like to save 90 percent of the space occupied by locales in their system, by limiting the number of installed locales to the bare minimum.
[edit] Pre glibc 2.3.6 r4 method
Add the userlocales USE flag to the glibc package. You can do this by adding it to /etc/portage/package.use with: echo "sys-libs/glibc userlocales" >> /etc/portage/package.use
Now specify the locales you want to be able to use in /etc/locales.build as in the example below.
| File: /etc/locales.build |
en_US/ISO-8859-1 en_US.UTF-8/UTF-8 de_DE/ISO-8859-1 de_DE@euro/ISO-8859-15 de_DE.UTF-8/UTF-8 |
The entries in the file are, like the header of the file suggests, in the format <locale>/<charmap> code>. <locale> code> is a locale from the /usr/share/i18n/locales directory and <charmap> code> is the name of one of the files in /usr/share/i18n/charmaps/.
[edit] glibc 2.3.6 r4 and above
Since glibc-2.3.6-r4 the uselocales flag has been removed and /etc/userlocales.build has been replaced with /etc/locale.gen. All you need to do is simply specify which locales you want in /etc/locale.gen and then run locale-gen.
The format is basically the same as locales.build, except the / is replaced with a space. The following example shows a British system with the ISO-8859-1 and UTF-8 character sets enabled.
| File: /etc/locale.gen |
en_GB ISO-8859-1 en_GB.UTF-8 UTF-8 |
[edit] Undefined locales
If you need to install a locale not yet defined in /usr/share/i18n/locales, please refer to the Gentoo official UTF-8 documentation.
[edit] See also
For further information about locale-handling read the Gentoo Linux Localization Guide.
[edit] Additional tools
Another interesting tool is app-admin/localepurge which can clean out any installed man-page or info-file in languages you don't need on your system. You should read the man-page to localepurge in any case and configure languages you intend to keep in /etc/locale.nopurge.
