<?xml version='1.0' encoding='UTF-8'?>
<!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/guide-localization.xml,v 1.30 2005/08/20 16:35:31 swift Exp $ -->
<!DOCTYPE guide SYSTEM "/dtd/guide.dtd">

<guide link="/doc/en/guide-localization.xml">
<title>Gentoo Linux Localization Guide</title>
<author title="Author">
  Alexander Holler
</author>
<author title="Translator/Editor">
  <mail link="slucy@uchicago.edu">Steven Lucy</mail>
</author>
<author title="Editor">
  <mail link="bennyc@gentoo.org">Benny Chuang</mail>
</author>
<author title="Editor">
  <mail link="pylon@gentoo.org">Lars Weiler</mail>
</author>
<author title="Editor">
  <mail link="dertobi123@gentoo.org">Tobias Scherbaum</mail>
</author>
<author title="Editor">
  <mail link="flammie@gentoo.org">Flammie Pirinen</mail>
</author>

<abstract>
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.
</abstract>

<version>1.21</version>
<date>2005-08-20</date>

<chapter>
<title>Time zone</title>
<section>
<body>

<p>
In order to keep time properly, <path>/etc/localtime</path> must point to
the correct time zone data file.  Look around in
<path>/usr/share/zoneinfo/</path> and pick your timezone or a near-by big city.
</p>

<pre caption="setting the timezone">
# <i>ln -sf /usr/share/zoneinfo/Europe/Berlin /etc/localtime</i>
# <i>date</i>
Sun Feb 16 08:26:44 CET 2003
</pre>

<note>
Make sure that the three-letter timezone indicator (in this case "CET")
is correct for your area.
</note>

<note>
You can set the value of <c>TZ</c> to be everything after the
<path>/usr/share/zoneinfo</path> in your shell rc file
(<path>.bash_profile</path> for bash) for a user-level setting.  In this case
<c>TZ="Europe/Berlin"</c>.
</note>

</body>
</section>
</chapter>

<chapter>
<title>Hardware Clock</title>
<section>
<body>

<p>
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 <path>/etc/conf.d/clock</path> and change the
value of <c>CLOCK</c> from <c>UTC</c> to <c>local</c>.
</p>

<pre caption="local vs. GMT clock">
<comment>(recommended:)</comment>
CLOCK="UTC"
<comment>(or:)</comment>
CLOCK="local"
</pre>

</body>
</section>
</chapter>

<chapter>
<title>Locale system</title>
<section>
<title>What are locales?</title>
<body>

<p>
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 <path>/usr/share/locale</path> on most systems. A locale name is generally
named <c>ab_CD</c> where <c>ab</c> is your two (or three) letter
language code (as specified in ISO-639) and <c>CD</c> is your two letter country
code (as specified in ISO-3199).
</p>

</body>
</section>
<section>
<title>Environment variables for locales</title>
<body>

<p>
Locale settings are stored in environment variables. These are typically
set in the <path>/etc/env.d/02locale</path> (for system-wide
settings) and <path>~/.bashrc</path> (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 <c>ab_CD</c> format given above.
</p>

<table>
<tr>
  <th>Variable name</th>
  <th>Explanation</th>
</tr>
<tr>
  <ti>LC_ALL</ti>
  <ti>
    Define all locale settings at once. This is the top level setting for
    locales which will override any other setting.
  </ti>
</tr>
<tr>
  <ti>LC_COLLATE</ti>
  <ti>
    Define alphabetical ordering of strings. This affects eg. output of sorted
    directory listing.
  </ti>
</tr>
<tr>
  <ti>LC_CTYPE</ti>
  <ti>
    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.
  </ti>
</tr>
<tr>
  <ti>LC_MESSAGES</ti>
  <ti>
    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).
  </ti>
</tr>
<tr>
  <ti>LC_MONETARY</ti>
  <ti>Defines currency units and formatting of currency type numeric values.</ti>
</tr>
<tr>
  <ti>LC_NUMERIC</ti>
  <ti>
    Defines formatting of numeric values which aren't monetary. Affects things
    such as thousand separator and decimal separator.
  </ti>
</tr>
<tr>
  <ti>LC_TIME</ti>
  <ti>Defines formatting of dates and times.</ti>
</tr>
<tr>
  <ti>LC_PAPER</ti>
  <ti>Defines default paper size.</ti>
</tr>
<tr>
  <ti>LANG</ti>
  <ti>
    Defines all locale settings at once. This setting can be overridden by
    individual LC_* settings above or even by LC_ALL.
  </ti>
</tr>
</table>

<note>
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 <e>both</e>.
</note>

<p>
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:
</p>

<pre caption="setting the German locale">
export LANG="de_DE@euro"
</pre>

<note>
Append <c>@euro</c> to your locale if you want to use the Euro
currency symbol (&#8364;)
</note>

<p>
For message based localization to work in programs that support it, you will
probably need to have programs compiled with the <c>nls</c> (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.
</p>

</body>
</section>
<section>
<title>Generating Specific Locales</title>
<body>

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

<pre caption="Generating a locale using localedef">
# <i>localedef -c -i en_US -f ISO-8859-15 en_US.ISO-8859-15</i>
</pre>

<p>
After having generated the locale, you can export the LANG variable as you see
fit.
</p>

<pre caption="Exporting the LANG variable">
# <i>export LANG="en_US.ISO-8859-15"</i>
</pre>

</body>
</section>
<section>
<title>The userlocales USE flag</title>
<body>

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

<pre caption="Activate the userlocales USE flag especially for glibc">
echo "sys-libs/glibc userlocales" >> /etc/portage/package.use
</pre>

<p>
Now specify the locales you want to be able to use:
</p>

<pre caption="Adding locales to /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
</pre>

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

</body>
</section>
</chapter>

<chapter>
<title>Keyboard layout for the console</title>
<section>
<body>

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

<pre caption="setting the console keymap">
KEYMAP="de"
KEYMAP="de-latin1"
KEYMAP="de-latin1-nodeadkeys"
</pre>

</body>
</section>
</chapter>

<chapter>
<title>Keyboard layout for the X server</title>
<section>
<body>

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

<pre caption="setting the X keymap">
 Section "InputDevice"
     Identifier  "Keyboard1"
     ...
     Option "XkbLayout"    "de"
     # Option "XkbVariant"  "nodeadkeys"
     ...
</pre>

</body>
</section>
</chapter>

<chapter>
<title>KDE</title>
<section>
<body>

<p>
For KDE you have to install the kde-i18n package with the appropriate
LINGUAS variable set:
</p>

<pre caption="Install localized KDE">
# <i>nano -w /etc/make.conf</i>
<comment>(Add in the LINGUAS variable. For instance, for the German language:)</comment>
LINGUAS="de"

<comment>(Now install kde-i18n)</comment>
# <i>emerge kde-i18n</i>
</pre>

</body>
</section>
</chapter>

<chapter>
<title>The Euro Symbol for the Console</title>
<section>
<body>

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

<pre caption="setting the console font">
CONSOLEFONT="lat9w-16"
</pre>

</body>
</section>
</chapter>

<chapter>
<title>The Euro Symbol in X</title>
<section>
<title>Most Applications</title>
<body>

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

<pre caption="setting default X fonts">
fixed        -misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-iso8859-15
variable     -*-helvetica-bold-r-normal-*-*-120-*-*-*-*-iso8859-15
</pre>

<p>
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
<path>.Xdefaults</path> (you can copy this file to
<path>/etc/skel/</path> for use by new users), or at a global
level for any application with a resource file in
<path>/usr/X11R6/lib/X11/app-defaults/</path> (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:
</p>

<pre caption="setting fonts for xterm">
<comment>(in your home directory)</comment>
# <i>echo 'XTerm*font: fixed' >> .Xresources </i>
# <i>xrdb -merge .Xresources</i>
</pre>

</body>
</section>
<section>
<title>The Euro symbol in (X)Emacs</title>
<body>

<p>
To use the Euro symbol in (X)Emacs, add the following to
<path>.Xdefaults</path>:
</p>

<pre caption="setting the font for emacs">
Emacs.default.attributeFont: -*-courier-medium-r-*-*-*-120-*-*-*-*-iso8859-15
</pre>

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

<pre caption="setting the font for xemacs">
(define-key global-map '(EuroSign) '[&#8364;])
</pre>

<note>
The symbol in the []s is the Euro symbol.
</note>

</body>
</section>
<section>
<title>Language for OpenOffice.org</title>
<body>

<note>
Customized default language is not available for openoffice-bin ebuild. The
default language in the openoffice-bin is ENUS.
</note>

<p>
Please note that this package now uses the LINGUAS variable to
provide localization. The old LANGUAGE=ENUS|PORT system does <e>not</e> work
anymore. The default language for OpenOffice.org is set as "US English". If you
wish to change the default language for OpenOffice.org, check the ebuild for the
default language code.
</p>

<pre caption="Example: emerge openoffice for german + english environment">
# <i>nano -w /etc/make.conf</i>
<comment>(Add in the LINGUAS variable. For instance, for the German and English language:)</comment>
LINGUAS="de en"

<comment>(Now install openoffice)</comment>
# <i>emerge openoffice</i>
</pre>

</body>
</section>
</chapter>

</guide>
