<!--
     The FreeBSD Documentation Project
     The FreeBSD German Documentation Project

     Original Revision 1.39
     $FreeBSD$
     $FreeBSDde: de-docproj/books/handbook/l10n/chapter.sgml,v 1.3 2002/03/17 18:10:21 mheinen Exp $
-->

<chapter id="l10n">
  <title>Lokalisierung - I18N/L10N Einrichtung und Benutzung</title>

  <para><emphasis>Geschrieben von &a.ache;</emphasis></para>

  <para><emphasis>&Uuml;berarbeitet von Michael Chin-Yuan Wu
    <email>keichii@mail.utexas.edu</email>, 6 M&auml;rz 2000.</emphasis></para>

  <para><emphasis>&Uuml;bersetzt von &a.alex;, Juli 2000.</emphasis></para>

  <sect1>
    <title>&Uuml;bersicht</title>

    <para>Dieser Teil des Handbuchs behandelt die Internationalisierung
      und die lokale Anpassung von FreeBSD and die Bed&uuml;rfnisse der
      verschiedenen L&auml;nder und deren Gegebenheiten.
      Wenn der Benutzer eine andere Sprache als die vorgegebene
      Standard-Einstellung, Englisch, benutzen m&ouml;chte, mu&szlig;
      er das System entsprechend einrichten.  Bitte beachten Sie,
      da&szlig; Unterst&uuml;tzung f&uuml;r verschiedene Sprachen im
      Umfang variiert.  Von daher sollte jeder FreeBSD Benutzer sich
      mit der Gruppe in Verbindung setzen, die f&uuml;r die
      Sprach&uuml;nterst&uuml;tung f&uuml;r seine Sprache
      zust&auml;ndig ist.</para>
                                                                     
    <para>Der Autor bemerkt, da&szlig; seine Beschreibung des i18n
      Prozesses eventuell unvollst&auml;ndig sein kann. Wegen der
      Unterschiede unter den einzelnen Sprachanpassungen empfehlen wir
      Ihnen, Dokumentation, die direkt auf Ihre Sprache zugeschnitten
      ist, wie Manpages, READMEs usw., zu konsultieren.</para>

    <para>Sollten Sie weitere Fragen oder Vorschl&auml;ge haben,
      schreiben Sie bitte dem Autor.</para>
  </sect1>

  <sect1>
    <title>Grundlagen</title>

    <sect2>
      <title>Was ist i18n/l10n?</title>

      <para>Entwickler k&uuml;rzen das Wort <quote>internationalization</quote>
        (englisch f&uuml;r <quote>Internationalisierung</quote>) auf
        die Buchstaben <quote>i18n</quote> ab, wobei <quote>18</quote>
        die Anzahl der Buchstaben zwischen erstem und letzten
        Buchstaben des Wortes ist.  l10n benutzt die gleiche
        Namensgebung, eine Abk&uuml;rzung des Wortes
        <quote>localization</quote> (englisch f&uuml;r
        <quote>Lokalisierung</quote>, <quote>lokale Anpassung</quote>).
        Kombiniert erlauben die i18n/l10n Methoden den Benutzern,
        Protokolle und Anwendungen an Ihre Vorlieben
        anzupassen.</para>

      <para>I18n Anwendungen wurden programmiert mit Hilfe von i18n
        Bibliotheken. Diese erlauben es Entwicklern, eine einfache
        Sprach-Datei zu schreiben und Men&uuml;leisten und Texte
        so an jede Sprache anzupassen.
        Wir m&ouml;chten Programmierern empfehlen,
        f&uuml;r ihre eigenen Anwendungen auf diese Techniken
        zur&uuml;ckzugreifen.</para> 
    </sect2>

    <sect2>
      <title>Wieso soll ich i18n/l10n Benutzen?</title>

      <para>I18n/l10n wird immer dann benutzt, wenn Sie Anzeigen,
        Eingaben oder die Verarbeitung von Daten in Sprachen anders
        als Englisch w&uuml;nschen.</para>
    </sect2>

    <sect2>
      <title>Welche Sprachen werden von i18n unterst&uuml;tzt?</title>

      <para>I18n and l10n sind nichts FreeBSD spezifisches.
        Momentan k&ouml;nnen Sie unter den meisten der verbreitetsten
        Sprachen der Welt w&auml;hlen, unter anderen Chinesisch,
        Japanisch, Franz&ouml;sisch, Russisch, aber auch
        Deutsch.</para>
    </sect2>
  </sect1>

  <sect1 id="using-localization">
    <title>Lokale Anpassungen benutzen</title>

    <para>In seiner ganzen Sch&ouml;nheit ist l10n nichts, was auf
      FreeBSD alleine beschr&auml;nkt ist, im Gegenteil, es ist eine
      Konvention, an die sich viele Programme f&uuml;r verschiedene
      Betriebssysteme halten. Wir m&ouml;chten Sie anregen, FreeBSD
      bei der Unterst&uuml;tzung dieser Konvention zu helfen.</para>

    <para>Lokale Anpassungen basieren auf drei Schlagw&ouml;rtern:
      Language Code, Country Code und Kodierung.  Locale Namen (die
      verschiedenen Anpassungen an eine Sprache werden
      <quote>Locale</quote> genannt) werden aus den oben genannten
      Schlagw&auml;rtern wie folgt zusammengesetzt:</para>

    <programlisting>
<replaceable>LanguageCode</replaceable>_<replaceable>CountryCode</replaceable>.<replaceable>Kodierung</replaceable></programlisting>

    <sect2>
      <title>Language und Country Codes</title>

      <para>Um ein FreeBSD (oder ein anderes UNIX, das i18n unterst&uuml;tzt)
        an lokale Gegenheiten und Sprachen anzupassen, mu&szlig; der
        Benutzer herausfinden, welche Codes f&uuml;r sein Land
        (<quote>Country</quote>) und seine Sprache
        (<quote>Language</quote>) benutzt werden.  Country Codes geben
        den Anwendungen dabei vor, welche Variation einer bestimmten
        Sprache zu benutzen ist. Eine Variation von Deutsch w&auml;re
        z.B. de_CH, das eine lokale Anpassung an das in der Schweiz
        gesprochene Deutsch meint.
        Au&szlig;erdem benutzen Webbrowser, SMTP/POP Server, Webserver
        usw. diese, um Entscheidungen &uuml;ber die Sprache zu
        f&auml;llen.  Im Folgenden sind einzige Beispiele f&uuml;r
        Language/Country Codes aufgelistet:</para>

      <informaltable frame="none">
        <tgroup cols="2">
          <thead>
            <row>
              <entry>Language/Country Code</entry>
              <entry>Beschreibung</entry>
            </row>
          </thead>

          <tbody>
            <row>
              <entry>en_US</entry>
              <entry>English - United States</entry>
            </row>

            <row>
              <entry>ru_RU</entry>
              <entry>Russisch f&uuml;r Russland</entry>
            </row>

            <row>
              <entry>zh_TW</entry>
              <entry>Traditionelles Chinesich f&uuml;r Taiwan</entry>
            </row>
          </tbody>
        </tgroup>
      </informaltable>
    </sect2>

    <sect2>
      <title>Kodierungen</title>

      <para>Einige Sprachen benutzen Kodierungen, die nicht dem 7-bit
        breitem ASCII-Standard entsprechend, so wie 8-bit Kodierungen
        oder wide- oder multibyte Characters. &man.mulltibyte.3;
        geht darauf n&auml;her ein. &Auml;ltere Anwendungen erkennen
        diese Zeichen nicht und halten sie f&auml;lschlicherweise
        f&uuml;r Kontroll-Zeichen. Neuere Anwendungen erkennen 8-bit
        Zeichen f&uuml;r gew&ouml;hnlich.  Es h&auml;ngt allerdings
        von der Implementierung ab, ob man eine Anwendung neu
        kompilieren mu&szlig;, um in den Genu&szlig; von lokalen
        Zeichens&auml;tzen kommt, oder ob man es sie nur
        nachtr&auml;glich konfigurieren mu&szlig;.
        Um es m&ouml;glich zu machen, wide oder multibyte Zeichen
        einzugeben und zu verarbeiten, unterst&uuml;tzt die <ulink
        url="../ports/">FreeBSD Ports Collection</ulink>
        verschiedene Sprachen f&uuml;r diverse Programme.  Bitte
        konsultieren Sie die i18n Dokumentation des entsprechenden
        FreeBSD-Ports.</para>

      <para>In den meisten F&auml;llen mu&szlig; der Benutzer in die
        Dokumentation des Programmes schauen, um herauszufinden, wie
        man es entsprechend f&uuml;r die eigene Sprache und
        Zeichens&auml;tze konfiguriert, oder welche Optionen beim
        Compilieren zu setzen sind.</para>

     <para>Einige Dinge, die man im Hinterkopf behalten sollte, sind:</para>

      <itemizedlist>
        <listitem>
          <para>Sprach-bezogene einzelne Zeichens&auml;tze
            (siehe &man.multibyte.3;), d.h. ISO_8859-1, KOI8-R, CP437.</para>
        </listitem>

        <listitem>
          <para>Wide oder multibyte Kodierungen, d.h. EUC, Big5.</para>
        </listitem>
      </itemizedlist>

      <para>Eine aktuelle Liste der Zeichens&auml;tze ist
      verf&uuml;gbar in der
      <ulink
        url="ftp://ftp.isi.edu/in-notes/iana/assignments/character-sets">IANA Registry</ulink>.</para>
    </sect2>

    <sect2>
      <title>I18n Anwendungen</title>

      <para>Im FreeBSD Ports und Paket-System werden i18n Anwendungen
	mit einem <literal>i18n</literal> im Namen gekennzeichnet,
	damit man sie leicht identifizieren kann.  Trotzdem kann es
	vorkommen, dass die ben&ouml;tigte Sprache nicht immer
	unterst&uuml;tzt wird.</para>
    </sect2>

    <sect2 id="setting-locale">
      <title>Einstellen der Locale</title>

      <para>Theoretisch mu&szlig; man nur den Wert der
        <envar>LANG</envar> variable in der Loginshell setzen, was
	normalerweise in der <filename>~/.login_conf</filename> des
	users oder in der Login-Shell-Konfiguration
	configuration (<filename>~/.profile</filename>,
	<filename>~/.bashrc</filename>, <filename>~/.cshrc</filename>)
	passiert.
	Dieses sollte alle spezielleren Variablen, wie
	<envar>LC_CTYPE</envar>, <envar>LC_CTIME</envar> usw.,
	setzen.  Sie sollten sprach-bezogene FreeBSD Dokumentation
	zu Rate ziehen, wenn Sie mehr Informationen w&uuml;nschen.</para>

      <para>Sie sollten die zwei folgenden Variablen in Ihren
        Konfigurations-Dateien setzen:</para>

      <itemizedlist>
        <listitem>
	  <para><envar>LANG</envar> f&uuml;r Funktionen der
	    POSIX &man.setlocale.3; Familie</para>
	</listitem>

        <listitem>
	  <para><envar>MM_CHARSET</envar> f&uuml;r den MIME
	    Zeichensatz der Anwendungen</para>
	</listitem>
      </itemizedlist>

      <para>Dieses schlie&szlig;t die Shell-Konfiguration, die
	Konfiguration jeder Anwendung und die X11 Konfiguration ein.</para>

      <sect3>
	<title>Einstellen der Locale - Methoden</title>
	<!-- XXX HAE??? -->

	<para>Es gibt zwei Wege, die Locale zu setzen, und beide
	  werden im Folgenden beschrieben.
	  Die erste (und empfohlene) Methode ist, die
	  Umgebungsvariablen in der
	  <link linkend="login-class">Login-Klasse</link>
	  zu setzen, die zweite ist, sie in den
	  <link linkend="startup-file">Start-Dateien</link>
	  der Shell zu setzen.</para>

	<sect4 id="login-class">
	  <title>Login Classes Method</title>

	  <para>This method allows environment variables needed for locale
    name and MIME character sets to be assigned once for every
    possible shell instead of adding specific shell assignments to
    each shell's startup file.  <link linkend="usr-setup">User
    Level Setup</link> can be done by an user himself and <link
    linkend="adm-setup">Administrator Level Setup</link> require
    superuser privileges.</para>

  <sect5 id="usr-setup">
    <title>User Level Setup</title>

    <para>Here is a minimal example of a
      <filename>.login_conf</filename> file in user's home
      directory which has both variables set for Latin-1
      encoding:</para>

    <programlisting>
me:My Account:\
:charset=ISO-8859-1:\
:lang=de_DE.ISO_8859-1:</programlisting>

    <para>See <link linkend="adm-setup">Administrator Level
      Setup</link> and &man.login.conf.5; for more details.</para>
  </sect5>

  <sect5 id="adm-setup">
    <title>Administrator Level Setup</title>

    <para>Check that <filename>/etc/login.conf</filename> have the
      correct language user's class.  Make sure these settings
      appear in <filename>/etc/login.conf</filename>:</para>

    <programlisting>
<replaceable>language_name</replaceable>:<replaceable>accounts_title</replaceable>:\
:charset=<replaceable>MIME_charset</replaceable>:\
:lang=<replaceable>locale_name</replaceable>:\
:tc=default:</programlisting>

    <para>So sticking with our previous example using Latin-1, it
      would look like this:</para>

    <programlisting>
german:German Users Accounts:\
:charset=ISO-8859-1:\
:lang=de_DE.ISO_8859-1:\
:tc=default:</programlisting>

    <para>Changing Login Classes with &man.vipw.8;</para>

    <para>Use <command>vipw</command> to add new users, and make
      the entry look like this:</para>

    <programlisting>
user:password:1111:11:<replaceable>language</replaceable>:0:0:User Name:/home/user:/bin/sh</programlisting>

    <para>Changing Login Classes with &man.adduser.8;</para>

    <para>Use <command>adduser</command> to add new users, and do
      the following:</para>

    <itemizedlist>
      <listitem>
<para>Set <literal>defaultclass =
  <replaceable>language</replaceable></literal> in
  <filename>/etc/adduser.conf</filename>.  Keep in mind
  you must enter a <literal>default</literal> class for
  all users of other languages in this case.</para>
      </listitem>

      <listitem>
<para>An alternative variant is answering the specified
  language each time that 
<screen><prompt>Enter login class: default []: </prompt></screen>
  appears from &man.adduser.8;</para>
      </listitem>

      <listitem>
<para>Another alternative is to use the following for each
  user of a different language that you wish to
  add:</para>

<screen>&prompt.root; <userinput>adduser -class <replaceable>language</replaceable></userinput></screen>
      </listitem>
    </itemizedlist>

    <para>Changing Login Classes with &man.pw.8;</para>

    <para>If you use &man.pw.8; for adding new users, call it in
      this form:</para>

    <screen>&prompt.root; <userinput>pw useradd <replaceable>user_name</replaceable> -L <replaceable>language</replaceable></userinput></screen>
  </sect5>
</sect4>

<sect4 id="startup-file">
  <title>Shell Startup File Method</title>

  <note>
    <para>This method is not recommended because it requires a
      different setup for each possible login program chosen.  Use
      the <link linkend="login-class">Login Class Method</link>
      instead.</para>
  </note>

  <para>To add the locale name and MIME character set, just set
    the two environment variables shown below in the
    <filename>/etc/profile</filename> and/or
    <filename>/etc/csh.login</filename> shell startup files.  We
    will use the German language as an example below:</para>

  <para>In <filename>/etc/profile</filename>:</para>

  <programlisting>
<envar>LANG=de_DE.ISO_8859-1; export LANG</envar>
<envar>MM_CHARSET=ISO-8859-1; export MM_CHARSET</envar></programlisting>

  <para>Or in <filename>/etc/csh.login</filename>:</para>

  <programlisting>
<envar>setenv LANG de_DE.ISO_8859-1</envar>
<envar>setenv MM_CHARSET ISO-8859-1</envar></programlisting>

  <para>Alternatively, you can add the above instructions to
    <filename>/usr/share/skel/dot.profile</filename> (similar to
    what was used in <filename>/etc/profile</filename> above), or
    <filename>/usr/share/skel/dot.login</filename> (similar to
    what was used in <filename>/etc/csh.login</filename>
    above).</para>

  <para>For X11:</para>

  <para>In <filename>$HOME/.xinitrc</filename>:</para>

  <programlisting>
<envar>LANG=de_DE.ISO_8859-1; export LANG</envar></programlisting>

  <para>Or:</para>

  <programlisting>
<envar>setenv LANG de_DE.ISO_8859-1</envar></programlisting>

  <para>Depending on your shell (see above).</para>
</sect4>
      </sect3>
    </sect2>

    <sect2 id="setting-console">
      <title>Console Setup</title>

      <para>For all single C chars character sets, set the correct
console fonts in <filename>/etc/rc.conf</filename> for the
language in question with:</para>

      <programlisting>
font8x16=<replaceable>font_name</replaceable>
font8x14=<replaceable>font_name</replaceable>
font8x8=<replaceable>font_name</replaceable></programlisting>

      <para>The <replaceable>font_name</replaceable> here is taken from
        the <filename>/usr/share/syscons/fonts</filename> directory,
without the <filename>.fnt</filename> suffix.</para>

      <para>Also be sure to set the correct keymap and screenmap for your
single C chars character set through
<filename>/stand/sysinstall</filename>.
Once inside sysinstall, choose <literal>Configure</literal>, then
<literal>Console</literal>.  Alternatively, you can add the
following to <filename>/etc/rc.conf</filename>:</para>

      <programlisting>
scrnmap=<replaceable>screenmap_name</replaceable>
keymap=<replaceable>keymap_name</replaceable>
keychange="<replaceable>fkey_number sequence</replaceable>"</programlisting>

      <para>The <replaceable>screenmap_name</replaceable> here is taken
        from the <filename>/usr/share/syscons/scrnmaps</filename>
directory, without the <filename>.scm</filename> suffix.  A
screenmap with a corresponding mapped font is usually needed as a
workaround for expanding bit 8 to bit 9 on a VGA adapter's font
character matrix in pseudographics area, i.e., to move letters out
of that area if screen font uses a bit 8 column.</para>

      <para>If you have the following settings, insert the 
kernel config specified in the paragraph after the list.</para>	

      <itemizedlist>
<listitem>
  <para>Console uses a screen font that utilizes 8-bit column font
    character.</para>
</listitem>

<listitem>
  <para>The moused daemon is enabled by setting the following in
    your <filename>/etc/rc.conf</filename>:</para>

<programlisting>moused_enable="YES"</programlisting>
</listitem>  
      </itemizedlist>

      <para>A workaround for expanding 8-bit to 9-bit on a VGA adapter
is usually needed for the above settings.  This workaround
disables 8-bit to 9-bit expansion of the font character with the
mouse cursor the sc0 console driver.  To enable the workaround,
insert the following line into the kernel config.</para>

      <programlisting>
options         SC_MOUSE_CHAR=0x03</programlisting>

      <para>The <replaceable>keymap_name</replaceable> here is taken from
        the <filename>/usr/share/syscons/keymaps</filename> directory,
without the <filename>.kbd</filename> suffix.</para>

      <para>The <literal>keychange</literal> is usually needed to program
        function keys to match the selected terminal type because
function key sequences can not be defined in the key map.</para>

      <para>Also be sure to set the correct console terminal type in
        <filename>/etc/ttys</filename> for all <literal>ttyv*</literal>
entries.  Current pre-defined correspondences are:</para>

      <informaltable frame="none">
<tgroup cols="2">
  <thead>
    <row>
      <entry>Character Set</entry>
      <entry>Terminal Type</entry>
    </row>
  </thead>

  <tbody>
    <row>
      <entry>ISO-8859-1 or ISO-8859-15</entry>
      <entry><literal>cons25l1</literal></entry>
    </row>

    <row>
      <entry>ISO-8859-2</entry>
      <entry><literal>cons25l2</literal></entry>
    </row>

    <row>
      <entry>KOI8-R</entry>
      <entry><literal>cons25r</literal></entry>
    </row>

    <row>
      <entry>CP437 (hardware default)</entry>
      <entry><literal>cons25</literal></entry>
    </row>
  </tbody>
</tgroup>
      </informaltable>

      <para>For wide or multibyte characters languages, use the correct
FreeBSD port in your
<filename>/usr/ports/<replaceable>language</replaceable></filename>
directory.  Some ports appear as console while the system sees it
as serial vtty's, hence you must reserve enough vtty's for both
X11 and the pseudo-serial console.  Here is a partial list of
applications for using other languages in console:</para>

      <informaltable frame="none">
<tgroup cols="2">
  <thead>
    <row>
      <entry>Language</entry>
      <entry>Location</entry>
    </row>
  </thead>

  <tbody>
    <row>
      <entry>Traditional Chinese (BIG-5)</entry>
      <entry><filename>/usr/ports/chinese/big5con</filename></entry>
    </row>

    <row>
      <entry>Japanese</entry>
      <entry><filename>/usr/ports/japanese/ja-kon2-*</filename> or
        <filename>/usr/ports/japanese/Mule_Wnn</filename></entry>
    </row>

    <row>
      <entry>Korean</entry>
      <entry><filename>/usr/ports/korean/ko-han</filename></entry>
    </row>
  </tbody>
</tgroup>
      </informaltable>
    </sect2>

    <sect2>
      <title>X11 Setup</title>

      <para>Although X11 is not part of the FreeBSD Project, we have
included some information here for FreeBSD users.  For more
details, refer to the <ulink url="http://www.xfree86.org/">XFree86
web site</ulink> or whichever X11 Server you use.</para>

      <para>In <filename>~/.Xresources</filename>, you can additionally
tune application specific i18n settings (e.g., fonts, menus,
etc.).</para>

      <sect3>
<title>Displaying Fonts</title>

<para>Install the X11 True Type-Common server (XTT-common) and
  install the language truetype fonts.  Setting the correct
  locale should allow you to view your selected language in menus
  and such.</para>
      </sect3>

      <sect3>
<title>Inputting Non-English Characters</title>

<para>The X11 Input Method (XIM) Protocol is a new standard for
  all X11 clients.  All X11 applications should be written as XIM
  clients that take input from XIM Input servers.  There are
  several XIM servers available for different languages.</para>
      </sect3>
    </sect2>

    <sect2>
      <title>Printer Setup</title>

      <para>Some single C chars character sets are usually hardware
coded into printers. Wide or multibyte
character sets require special setup and we recommend using
<application>apsfilter</application>.  You may also convert the
document to Postscript or PDF formats using language specific
converters.</para>
    </sect2>

    <sect2>
      <title>Kernel and File Systems</title>

      <para>The FreeBSD FFS filesystem is 8-bit clean, so it can be used
with any single C chars character set (see &man.multibyte.3;),
but there is no character set
name stored in the filesystem; i.e., it is raw 8-bit and does not
know anything about encoding order.  Officially, FFS does not
support any form of wide or multibyte character sets yet.  However, some
wide or multibyte character sets have independent patches for FFS
enabling such support.  They are only temporary unportable
solutions or hacks and we have decided to not include them in the
source tree.  Refer to respective languages' web sites for more
informations and the patch files.</para>

      <para>The FreeBSD MS-DOS filesystem has the configurable ability to
convert between MS-DOS, Unicode character sets and chosen
FreeBSD filesystem character sets.  See &man.mount.msdos.8; for
details.</para>
    </sect2>
  </sect1>

  <sect1>
    <title>Advanced Topics</title>

    <para>If you wish to compile i18n applications or program i18n
      compliant applications, please read this section.</para>

    <sect2>
      <title>Compiling i18n Programs</title>

      <para>Many FreeBSD Ports have been ported with i18n support.  Some
of them are marked with -i18n in the port name.  These and many
other programs have built in support for i18n and need no special
consideration.</para>

      <para>However, some applications such as MySQL need to be have the
<filename>Makefile</filename> configured with the specific
charset.  This is usually done in the
<filename>Makefile</filename> or done by passing a value to
configure in the source.</para>
    </sect2>

    <sect2>
      <title>Programming i18n Compliant Applications</title>

      <para>To make your application more useful for speakers of other
languages, we hope that you will program i18n compliant.  The GNU
gcc compiler, GUI Libraries like QT and GTK support i18n through
special handling of strings.  Making a program i18n compliant is
very easy.  It allows contributors to port your application to
other languages quickly.  Refer to library specific i18n
documentation for more details.</para>

      <para>To the contrary of common perception, i18n compliant code is
easy to write.  Usually, it only involves wrapping your strings
with library specific functions.  In addition, please be sure to
allow for wide or multibyte characters support.</para>

      <sect3>
<title>A Call to Unify the i18n effort</title>

<para>It has come to our attention that the individual i18n/l10n
  efforts for each country has been repeating each others'
  efforts.  Many of us have been reinventing the wheel repeatedly
  and inefficiently.  We hope that the various major groups in
  i18n could congregate into a group effort similar to the Core
  Team's responsibility.</para>

<para>Currently, we hope that, when you write or port i18n
  programs, you would send it out to each country's related
  FreeBSD mailing lists for testing.  In the future, we hope to
  create applications that work in all the languages
  out-of-the-box without dirty hacks.</para>
      </sect3>

      <sect3>
<title>Perl and Python</title>

<para>Perl and Python have i18n and wide characters handling
  libraries.  Please use them for i18n compliance.</para>

<para>In older FreeBSD versions,
  Perl may gives warning about not having a wide characters locale
  that is already installed in your system.  You can set the
  environmental variable <envar>LD_PRELOAD</envar> to
  <filename>/usr/lib/libxpg4.so</filename> in your shell.</para>

<para>In <literal>sh</literal>-based shells:</para>

<programlisting>
<envar>LD_PRELOAD=/usr/lib/libxpg4.so</envar></programlisting>

<para>In <literal>C</literal>-based shells:</para>

<programlisting>
<envar>setenv LD_PRELOAD /usr/lib/libxpg4.so</envar></programlisting>
      </sect3>
    </sect2>
  </sect1>

  <sect1 id="lang-setup">
    <title>Localizing FreeBSD to Specific Languages</title>

    <sect2 id="ru-localize">
      <title>Russian Language (KOI8-R encoding)</title>

      <para><emphasis>Originally contributed by
        &a.ache;.</emphasis></para>

      <para>For more information about KOI8-R encoding, see the <ulink
url="http://nagual.pp.ru/~ache/koi8.html">KOI8-R References
(Russian Net Character Set)</ulink>.</para>

      <sect3>
<title>Locale Setup</title>

<para>Put the following lines into your
  <filename>~/.login_conf</filename> file:</para>

<programlisting>
me:My Account:\
:charset=KOI8-R:\
:lang=ru_RU.KOI8-R:</programlisting>

<para>See earlier in this chapter for examples of setting up the
  <link linkend="setting-locale">locale</link>.</para>
      </sect3>

      <sect3>
<title>Console Setup</title>

<itemizedlist>
  <listitem>
    <para>Add the following to your kernel configuration
      file:</para>

    <programlisting>
options		SC_MOUSE_CHAR=0x03</programlisting>
  </listitem>

  <listitem>
    <para>Use following settings in
      <filename>/etc/rc.conf</filename>:</para>

    <programlisting>
keymap="ru.koi8-r"
keychange="61 ^[[K"
scrnmap="koi8-r2cp866"
font8x16="cp866b-8x16"
font8x14="cp866-8x14"
font8x8="cp866-8x8"</programlisting>

    <para>Note that the <literal>^[</literal> here stands for a
      real Escape character (\033) entered directly in
      <filename>/etc/rc.conf</filename>, not for sequence of two
      characters '^' and '['.</para>
  </listitem>

  <listitem>
    <para>For each <literal>ttyv*</literal> entry in
      <filename>/etc/ttys</filename>, use
      <literal>cons25r</literal> as the terminal type.</para>
  </listitem>
</itemizedlist>

<para>See earlier in this chapter for examples of setting up the
  <link linkend="setting-console">console</link>.</para>
      </sect3>

      <sect3>
<title>Printer Setup</title>

<para>Since most printers with Russian characters come with
  hardware code page CP866, a special output filter is needed for
  KOI8-R -&gt; CP866 conversion.  Such a filter is installed by
  default as <filename>/usr/libexec/lpr/ru/koi2alt</filename>.
  A Russian printer <filename>/etc/printcap</filename> entry
  should look like:</para>

<programlisting>
lp|Russian local line printer:\
:sh:of=/usr/libexec/lpr/ru/koi2alt:\
:lp=/dev/lpt0:sd=/var/spool/output/lpd:lf=/var/log/lpd-errs:</programlisting>

<para>See &man.printcap.5; for a detailed description.</para>
      </sect3>

      <sect3>
<title>MS-DOS FS and Russian Filenames</title>

<para>The following example &man.fstab.5; entry enables support
  for Russian filenames in mounted MS-DOS filesystems:</para>

<programlisting>
/dev/ad0s2      /dos/c  msdos   rw,-W=koi2dos,-L=ru_RU.KOI8-R 0 0</programlisting>

<para>See &man.mount.msdos.8; for a detailed description of the
  <option>-W</option> and <option>-L</option> options.</para>
      </sect3>

      <sect3>
<title>X11 Setup</title>

<orderedlist>
  <listitem>
    <para>Do <link linkend="setting-locale">non-X locale
      setup</link> first as described.</para>

    <note>
      <para><anchor id="russian-note">The Russian KOI8-R locale
may not work with old XFree86 releases (lower than 3.3).
The XFree86 port from
<filename>/usr/ports/x11/XFree86</filename> already is the
most recent XFree86 version, so it will work if you
install XFree86 from the port.  This should not be an
issue unless you are using an old version of
FreeBSD.</para>
    </note>
  </listitem>

  <listitem>
    <para>Go to the
      <filename>/usr/ports/russian/X.language</filename> directory
      and issue the following command:</para>

    <screen>&prompt.root; <userinput>make install</userinput></screen>
      
    <para>The above port installs the latest version of the KOI8-R
      fonts.  XFree86 3.3 already has some KOI8-R fonts, but these
      are scaled better.</para>

    <para>Check the <literal>"Files"</literal> section
      in your <filename>/etc/XF86Config</filename> file.
      The following
      lines must be added <emphasis>before</emphasis> any other
      <literal>FontPath</literal> entries:</para>

    <programlisting>
FontPath   "/usr/X11R6/lib/X11/fonts/cyrillic/misc"
FontPath   "/usr/X11R6/lib/X11/fonts/cyrillic/75dpi"
FontPath   "/usr/X11R6/lib/X11/fonts/cyrillic/100dpi"</programlisting>

    <para>If you use a high resolution video mode, swap the 75 dpi
      and 100 dpi lines.</para>
  </listitem>

  <listitem>
    <para>To activate a Russian keyboard, add the following to the
      <literal>"Keyboard"</literal> section of your
      <filename>XF86Config</filename> file:</para>

    <programlisting>
XkbLayout  "ru"
XkbOptions "grp:caps_toggle"</programlisting>

    <para>Also make sure that <literal>XkbDisable</literal> is
      turned off (commented out) there.</para>

    <para>The RUS/LAT switch will be <literal>CapsLock</literal>.
      The old <literal>CapsLock</literal> function is still
      available via <literal>Shift+CapsLock</literal> (in LAT mode
      only).</para>

    <para>If you have <quote>Windows</quote> keys on your keyboard,
      and notice that some non-alphabetical keys are mapped
      incorrectly in RUS mode, add the following line in your
      <filename>XF86Config</filename> file:</para>

<programlisting>
XkbVariant "winkeys"</programlisting>

    <note>
      <para>The Russian XKB keyboard may not work with old XFree86
versions, see the <link linkend="russian-note">above
note</link> for more information.  The Russian XKB
keyboard may also not work with non-localized
applications as well.  Minimally localized applications
should call a <literal>XtSetLanguageProc (NULL, NULL,
NULL);</literal> function early in the program.
See <ulink
url="http://nagual.pp.ru/~ache/koi8/xwin.html">
KOI8-R for X-Window</ulink> for more instructions on
localizing X11 applications.</para>
    </note>
  </listitem>
</orderedlist>
      </sect3>
    </sect2>

    <sect2>
      <title>Traditional Chinese Localization for Taiwan</title>

      <para>The FreeBSD-Taiwan Project has an i18n/l10n tutorial for
FreeBSD at <ulink url="http://freebsd.sinica.edu.tw/~ncvs/zh-l10n-tut/index.html">http://freebsd.sinica.edu.tw/~ncvs/zh-l10n-tut/index.html</ulink>
using many <filename>/usr/ports/chinese/*</filename> applications.
The editor for the <literal>zh-l10n-tut</literal> is Clive Lin
<email>Clive@CirX.org</email>.  You can also cvsup the following
collections at <hostid
role="fqdn">freebsd.sinica.edu.tw</hostid>:</para>

      <informaltable frame="none">
<tgroup cols="2">
  <thead>
    <row>
      <entry>Collection</entry>
      <entry>Description</entry>
    </row>
  </thead>

  <tbody>
    <row>
      <entry>outta-port tag=.</entry>
      <entry>Beta-quality Ports Collection for Chinese</entry>
    </row>

    <row>
      <entry>zh-l10n-tut tag=.</entry>
      <entry>Localizing FreeBSD Tutorial in BIG-5 Traditional
Chinese</entry>
    </row>

    <row>
      <entry>zh-doc tag=.</entry>
      <entry>FreeBSD Documentation Translation to BIG-5 Traditional
Chinese</entry>
    </row>
  </tbody>
</tgroup>
      </informaltable>

      <para>Chuan-Hsing Shen <email>s874070@mail.yzu.edu.tw</email> has
created the <ulink url="http://cnpa.yzu.edu.tw/~cfc/">Chinese
FreeBSD Collection (CFC)</ulink> using FreeBSD-Taiwan's
<literal>zh-l10n-tut</literal>.  The packages and the script files
are available at <ulink url="ftp://ftp.csie.ncu.edu.tw/OS/FreeBSD/taiwan/CFC/">ftp://ftp.csie.ncu.edu.tw/OS/FreeBSD/taiwan/CFC/</ulink>.</para>
    </sect2>

    <sect2>
      <title>German Language Localization (For All ISO 8859-1
Languages)</title>

      <para>Slaven Rezic <email>eserte@cs.tu-berlin.de</email> wrote a
tutorial how to use umlauts on a FreeBSD machine.  The tutorial
is written in German and available at <ulink
url="http://www.de.FreeBSD.org/de/umlaute/">http://www.de.FreeBSD.org/de/umlaute/</ulink>.</para>
    </sect2>

    <sect2>
      <title>Japanese and Korean Language Localization</title>

      <para>For Japanese, refer to <ulink
url="http://www.jp.FreeBSD.org/">http://www.jp.FreeBSD.org/</ulink>,
and for Korean, refer to <ulink
url="http://www.kr.FreeBSD.org/">http://www.kr.FreeBSD.org/</ulink>.</para>
    </sect2>

    <sect2>
      <title>Non-English FreeBSD Documentation</title>

      <para>Some FreeBSD contributors have translated parts of FreeBSD to
other languages.  They are available through links on the <ulink
url="../">main site</ulink> or in
<filename>/usr/share/doc</filename>.</para>
    </sect2>
  </sect1>
</chapter>
