Gentoo Linux Localization Guide Alexander Holler Steven Lucy Benny Chuang Lars Weiler Tobias Scherbaum Flammie Pirinen This guide should help users localize their Gentoo Linux distribution to any European locale. It uses Germany as a case-study, since it is translated from the German doc. Includes configuration for use of the euro currency symbol. 1.25 2006-01-02 Time zone

In order to keep time properly, /etc/localtime must contain the correct time zone data. Look around in /usr/share/zoneinfo/ and pick your timezone or a near-by big city. Please avoid the /usr/share/zoneinfo/Etc/GMT* timezones as their names do not indicate the expected zones. For instance, GMT-8 is in fact GMT+8.

# cp /usr/share/zoneinfo/Europe/Berlin /etc/localtime
# date
Sun Feb 16 08:26:44 CET 2003
Make sure that the three-letter timezone indicator (in this case "CET") is correct for your area. You can set the value of TZ to be everything after the /usr/share/zoneinfo in your shell rc file (.bash_profile for bash) for a user-level setting. In this case TZ="Europe/Berlin".
Hardware Clock

In most Gentoo Linux installations, your hardware clock is set to UTC (or GMT, Greenwich Mean Time) and then your timezone is taken into account to determine the actual, local time. If, for some reason, you need your hardware clock not to be in UTC, you will need to edit /etc/conf.d/clock and change the value of CLOCK from UTC to local.

(recommended:)
CLOCK="UTC"
(or:)
CLOCK="local"
Locale system
What are locales?

A Locale is a set of information that most programs use for determining country and language specific settings. The locales and their data are part of the system library and can be found at /usr/share/locale on most systems. A locale name is generally named ab_CD where ab is your two (or three) letter language code (as specified in ISO-639) and CD is your two letter country code (as specified in ISO-3199).

Environment variables for locales

Locale settings are stored in environment variables. These are typically set in the /etc/env.d/02locale (for system-wide settings) and ~/.bashrc (for user-specific settings) file. The variables controlling different aspects of locale settings are given in the table below, those with highest precedence (ie. those that override settings below them) are at the top of the table. All variables take one name of a locale in ab_CD format given above.

LC_ALL Define all locale settings at once. This is the top level setting for locales which will override any other setting. LC_COLLATE Define alphabetical ordering of strings. This affects eg. output of sorted directory listing. LC_CTYPE Define the character handling properties for the system. This determines which characters are seen as part of alphabet, numeric and so on. This also determines the character set used, if applicable. LC_MESSAGES Programs' localizations for applications that use message based localization scheme (majority of Gnu programs, see next chapters for closer information which do, and how to get the programs, that don't, to work). LC_MONETARYDefines currency units and formatting of currency type numeric values.LC_NUMERIC Defines formatting of numeric values which aren't monetary. Affects things such as thousand separator and decimal separator. LC_TIMEDefines formatting of dates and times.LC_PAPERDefines default paper size.LANG Defines all locale settings at once. This setting can be overridden by individual LC_* settings above or even by LC_ALL.
Variable name Explanation
Even though most programs work with LC_ALL only, some of them misbehave if LC_ALL is set but LANG isn't. If you want to play safe, set them both.

Most typically users only set the LANG variable and perhaps LC_CTYPE variable on user level by adding definitions to shells startup files defining the environment variable manually from command line:

export LANG="de_DE@euro"
Append @euro to your locale if you want to use the Euro currency symbol (€)

For message based localization to work in programs that support it, you will probably need to have programs compiled with the nls (Native language support) USE flag set. Most of the programs using nls also need the gettext library to extract and use localized messages. Of course, Gentoo's Portage will automatically install it when needed.

Once you have set the right locale, be sure to update your environment variables to make your system aware of the change:

# env-update && source /etc/profile

After this, you will need to kill your X server by pressing Ctrl-Alt-Backspace, log out, then log in as user.

Now, verify that the changes have taken effect:

$ env | grep -i LC_

There is also additional localisation variable called LINGUAS, which affects to localisation files that get installed in gettext-based programs, and decides used localisation for some specific software packages, such as kde-base/kde-i18n and app-office/openoffice. The variable takes in space-separated list of language codes, and suggested place to set it is /etc/make.conf:

# nano -w /etc/make.conf
(Add in the LINGUAS variable. For instance, 
for German, Finnish and English:)
LINGUAS="de fi en"
Generating Specific Locales

If you use a locale that isn't available by default, you should use localedef to generate your locale. For instance:

# localedef -c -i en_US -f ISO-8859-15 en_US.ISO-8859-15

After having generated the locale, you can export the LANG variable as you see fit.

# export LANG="en_US.ISO-8859-15"

Be sure to update the environment after the change:

# env-update && source /etc/profile

After this, you will need to kill your X server by pressing Ctrl-Alt-Backspace, log out, then log in as user.

The userlocales USE flag

You will probably only use one or maybe two locales on your system. Up until now after compiling glibc a full set of all available locales has been created. As of now you can activate the userlocales USE flag and specify only the locales you will need in /etc/locales.build.

echo "sys-libs/glibc userlocales" >> /etc/portage/package.use

Now specify the locales you want to be able to use:

en_US/ISO-8859-1
en_US.UTF-8/UTF-8
de_DE/ISO-8859-1
de_DE@euro/ISO-8859-15

The next step is to re-compile glibc. Of course you can defer this until the next glibc upgrade is available.

Keyboard layout for the console

The keyboard layout used by the console is set in /etc/conf.d/keymaps by the KEYMAP variable. Valid values can be found in /usr/share/keymaps/{arch}/. i386 has further subdivisions into layout (qwerty/, azerty/, etc.). Some languages have multiple options, so you may wish to experiment to decide which one fits your needs best.

KEYMAP="de"
KEYMAP="de-latin1"
KEYMAP="de-latin1-nodeadkeys"
Keyboard layout for the X server

The keyboard layout to be used by the X server is specified in /etc/X11/xorg.conf by the XkbLayout option.

 Section "InputDevice"
     Identifier  "Keyboard1"
     ...
     Option "XkbLayout"    "de"
     #Option "XkbModel"     "pc105"    ## this is for international keyboards.
     # Option "XkbVariant"  "nodeadkeys" ## this would be used for xterm input
     ...

If you have an international keyboard layout, you should set the option XkbModel to pc102 or pc105, as this will allow mapping of the additional keys specific to your keyboard.

Deadkeys allow you to press keys that will not show immediately but will be combined with another letter to produce a single character such as é,è,á,à, etc. Setting XkbVariant to nodeadkeys allows input these special characters into X terminals.

If you would like to switch between more than one keyboard layout (for example English and Russian), all you have to do is add a few lines to xorg.conf that specify the desired layouts and the shortcut command.

 Section "InputDevice"
     Identifier  "Keyboard1"
     ...
     Option "XkbLayout"    "us,ru"
     Option "XkbOptions"   "grp:alt_shift_toggle,grp_led:scroll"

Here, XkbOptions allows you to toggle between keyboard layouts by simply pressing Alt-Shift. This will also toggle the Scroll Lock light on or off, thanks to the grp_led:scroll option. This is a handy visual indicator of which keyboard layout you are using at the moment.

KDE

For KDE you have to install the kde-base/kde-i18n package. Kde-i18n respects LINGUAS variable described earlier.

The Euro Symbol for the Console

In order to get your console to display the Euro symbol, you will need to set CONSOLEFONT in /etc/conf.d/consolefont to a file found in /usr/share/consolefonts/ (without the .psfu.gz). lat9w-16 has the Euro symbol.

CONSOLEFONT="lat9w-16"

You should verify that CONSOLEFONT is in the boot runlevel:

# rc-update show | grep -i consolefont

If no runlevel is displayed for CONSOLEFONT, then add it to the proper level:

# rc-update add consolefont boot
The Euro Symbol in X
Most Applications

Getting the Euro symbol to work properly in X is a little bit tougher. The first thing you should do is change the fixed and variable definitions in /usr/X11R6/lib/X11/fonts/misc/fonts.alias to end in iso8859-15 instead of iso8859-1.

fixed        -misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-iso8859-15
variable     -*-helvetica-bold-r-normal-*-*-120-*-*-*-*-iso8859-15

Some applications use their own font, and you will have to tell them separately to use a font with the Euro symbol. You can do this at a user-specific level in .Xdefaults (you can copy this file to /etc/skel/ for use by new users), or at a global level for any application with a resource file in /usr/X11R6/lib/X11/app-defaults/ (like xterm). In these files you generally have to change an existing line, rather than adding a new one. To change our xterm font, for instance:

(in your home directory)
# echo 'XTerm*font: fixed' >> .Xresources 
# xrdb -merge .Xresources
The Euro symbol in (X)Emacs

To use the Euro symbol in (X)Emacs, add the following to .Xdefaults:

Emacs.default.attributeFont: -*-courier-medium-r-*-*-*-120-*-*-*-*-iso8859-15

For XEmacs (not plain Emacs), you have to do a little more. In /home/user/.xemacs/init.el, add:

(define-key global-map '(EuroSign) '[€])
The symbol in the []s is the Euro symbol.
OpenOffice.Org

The current app-office/openoffice (or -ximian) source ebuilds support LINGUAS variable for selecting installed GUI language packs. The current stable app-office/openoffice-bin binary ebuilds do not yet support LINGUAS variable, however, so in order to use localised OpenOffice.Org you must either install the source version, or, with your discretion, the unstable binary version. To see status of GUI translation, hyphenation, spell checking and other localisations on your language, please refer to OpenOffice.Org localisation web site.