Initial pass at improving the flow and readability of this section.

Several more commits to follow.

Sponsored by: iXsystems
This commit is contained in:
Dru Lavigne 2014-02-11 14:59:28 +00:00
parent 3d0aafc679
commit c67cd9e7df
Notes: svn2git 2020-12-08 03:00:23 +00:00
svn path=/head/; revision=43871

View file

@ -101,29 +101,27 @@
<indexterm><primary>locale</primary></indexterm> <indexterm><primary>locale</primary></indexterm>
<para>Localization settings are based on three main terms: <para>Localization settings are based on three components:
Language Code, Country Code, and Encoding. Locale names are the language code, country code, and encoding. Locale names are
constructed from these parts as follows:</para> constructed from these parts as follows:</para>
<programlisting><replaceable>LanguageCode</replaceable>_<replaceable>CountryCode</replaceable>.<replaceable>Encoding</replaceable></programlisting> <programlisting><replaceable>LanguageCode</replaceable>_<replaceable>CountryCode</replaceable>.<replaceable>Encoding</replaceable></programlisting>
<sect2>
<title>Language and Country Codes</title>
<indexterm><primary>language codes</primary></indexterm> <indexterm><primary>language codes</primary></indexterm>
<indexterm><primary>country codes</primary></indexterm> <indexterm><primary>country codes</primary></indexterm>
<para>In order to localize a &os; system to a specific language, <para>The <replaceable>LanguageCode</replaceable> and <replaceable>CountryCode</replaceable> are used
the user needs to determine the codes for the specific country to determine the country
and language as the country code tells applications which and the specific language
variation of the given language to use. The following are variation. <xref linkend="locale-lang-country"/> provides some
examples of language/country codes:</para> examples of <replaceable>LanguageCode</replaceable>_<replaceable>CountryCode</replaceable>:</para>
<informaltable frame="none" pgwide="1"> <table xml:id="locale-lang-country" frame="none" pgwide="1">
<title>Common Language and Country Codes</title>
<tgroup cols="2"> <tgroup cols="2">
<thead> <thead>
<row> <row>
<entry>Language/Country Code</entry> <entry>LanguageCode_Country Code</entry>
<entry>Description</entry> <entry>Description</entry>
</row> </row>
</thead> </thead>
@ -131,86 +129,49 @@
<tbody> <tbody>
<row> <row>
<entry>en_US</entry> <entry>en_US</entry>
<entry>English - United States</entry> <entry>English, United States</entry>
</row> </row>
<row> <row>
<entry>ru_RU</entry> <entry>ru_RU</entry>
<entry>Russian for Russia</entry> <entry>Russian, Russia</entry>
</row> </row>
<row> <row>
<entry>zh_TW</entry> <entry>zh_TW</entry>
<entry>Traditional Chinese for Taiwan</entry> <entry>Traditional Chinese, Taiwan</entry>
</row> </row>
</tbody> </tbody>
</tgroup> </tgroup>
</informaltable> </table>
<para>A complete listing of available locales can be found by
typing:</para>
<screen>&prompt.user; <userinput>locale -a</userinput></screen>
</sect2>
<sect2>
<title>Encodings</title>
<indexterm><primary>encodings</primary></indexterm> <indexterm><primary>encodings</primary></indexterm>
<indexterm><primary>ASCII</primary></indexterm> <indexterm><primary>ASCII</primary></indexterm>
<para>Some languages use non-ASCII encodings that are 8-bit, <para>Some languages, such as Chinese or Japanese, cannot be represented using ASCII characters
wide, or multibyte characters. For more information on these and require an extended language encoding using either
encodings, refer to &man.multibyte.3;. Older applications do wide or multibyte characters. Older applications
not recognize these encodings and mistake them for control may mistake these encodings for control
characters. Newer applications usually recognize 8-bit characters while newer applications usually recognize 8-bit
characters. Depending on the implementation, users may be characters. Depending on the implementation, users may be
required to compile an application with wide or multibyte required to compile an application with wide or multibyte
character support, or configure it correctly. To provide character support, or configure it correctly. The rest of
application support for wide or multibyte characters, the this section describes the various methods for configuring the
<link xlink:href="&url.base;/ports/index.html">&os; Ports locale on a &os; system. The next section will discuss the
Collection</link> contains programs for several languages. considerations for finding or compiling applications with i18n
Refer to the <acronym>i18n</acronym> documentation in the support.</para>
respective &os; port.</para>
<para>Specifically, the user needs to look at the application <para>A complete listing of available locales can be found by
documentation to decide how to configure it correctly or to typing:</para>
determine which compile options to use when building the
port.</para>
<para>Some things to keep in mind are:</para> <screen>&prompt.user; <userinput>locale -a | more</userinput></screen>
<itemizedlist> <para>To determine the current locale setting:</para>
<listitem>
<para>Language specific single C chars character sets
such as ISO8859-1, ISO8859-15, KOI8-R, and CP437. These
are described in &man.multibyte.3;.</para>
</listitem>
<listitem> <screen>&prompt.user; <userinput>locale</userinput></screen>
<para>Wide or multibyte encodings such as EUC and
Big5.</para>
</listitem>
</itemizedlist>
<para>The active list of character sets can be found at the
<link
xlink:href="http://www.iana.org/assignments/character-sets">IANA
Registry</link>.</para>
<note>
<para>&os; uses Xorg-compatible locale encodings
instead.</para>
</note>
<para>In the &os; Ports Collection, <acronym>i18n</acronym>
applications include <literal>i18n</literal> in their names
for easy identification. However, they do not always support
the language needed.</para>
</sect2>
<sect2 xml:id="setting-locale"> <sect2 xml:id="setting-locale">
<title>Setting Locale</title> <title>Setting Locale for Login Shell</title>
<para>Usually it is sufficient to export the value of the <para>Usually it is sufficient to export the value of the
locale name as <envar>LANG</envar> in the login shell. This locale name as <envar>LANG</envar> in the login shell. This
@ -246,9 +207,6 @@
specific application configuration, and the specific application configuration, and the
<application>Xorg</application> configuration.</para> <application>Xorg</application> configuration.</para>
<sect3>
<title>Setting Locale Methods</title>
<indexterm><primary>locale</primary></indexterm> <indexterm><primary>locale</primary></indexterm>
<indexterm><primary>login class</primary></indexterm> <indexterm><primary>login class</primary></indexterm>
@ -260,25 +218,20 @@
system's shell system's shell
<link linkend="startup-file">startup file</link>.</para> <link linkend="startup-file">startup file</link>.</para>
<sect4 xml:id="login-class"> <sect3 xml:id="login-class">
<title>Login Classes Method</title> <title>Login Classes Method</title>
<para>This method allows environment variables needed for <para>This method assigns the required environment variables for
locale name and MIME character sets to be assigned once locale name and MIME character sets
for every possible shell instead of adding specific shell for every possible shell.
assignments to each shell's startup file. This setup can be either be
<link linkend="usr-setup">User Level Setup</link> can be performed by each user or it can be performed for all users by the
performed by each user while superuser.</para>
<link linkend="adm-setup">Administrator Level Setup</link>
requires superuser privileges.</para>
<sect5 xml:id="usr-setup"> <para>This minimal example sets both variables for the
<title>User Level Setup</title> Latin-1 encoding. These lines were added to the
<filename>.login_conf</filename> in an individual user's
<para>This provides a minimal example of a home directory:</para>
<filename>.login_conf</filename> located in a user's
home directory which has both variables set for the
Latin-1 encoding:</para>
<programlisting>me:\ <programlisting>me:\
:charset=ISO-8859-1:\ :charset=ISO-8859-1:\
@ -291,7 +244,7 @@
for Traditional Chinese in BIG-5 encoding. More for Traditional Chinese in BIG-5 encoding. More
variables are set because some applications do not variables are set because some applications do not
correctly respect locale variables for Chinese, correctly respect locale variables for Chinese,
Japanese, and Korean.</para> Japanese, and Korean:</para>
<programlisting>#Users who do not wish to use monetary units or time formats <programlisting>#Users who do not wish to use monetary units or time formats
#of Taiwan can manually change each variable #of Taiwan can manually change each variable
@ -307,16 +260,11 @@ me:\
:charset=big5:\ :charset=big5:\
:xmodifiers="@im=gcin": #Set gcin as the XIM Input Server</programlisting> :xmodifiers="@im=gcin": #Set gcin as the XIM Input Server</programlisting>
<para>See <link linkend="adm-setup">Administrator Level <para>See &man.login.conf.5; for more
Setup</link> and &man.login.conf.5; for more
details.</para> details.</para>
</sect5>
<sect5 xml:id="adm-setup"> <para>Alternately, the superuser can configure all users of the system for localization. The following variables in the user's login class in
<title>Administrator Level Setup</title> <filename>/etc/login.conf</filename> set the correct
<para>Verify that the user's login class in
<filename>/etc/login.conf</filename> sets the correct
language:</para> language:</para>
<programlisting><replaceable>language_name</replaceable>|<replaceable>Account Type Description</replaceable>:\ <programlisting><replaceable>language_name</replaceable>|<replaceable>Account Type Description</replaceable>:\
@ -332,13 +280,14 @@ me:\
:lang=de_DE.ISO8859-1:\ :lang=de_DE.ISO8859-1:\
:tc=default:</programlisting> :tc=default:</programlisting>
<para>Whenever this file is edited, execute the following <para>Whenever <filename>/etc/login.conf</filename> is edited, remember to execute the following
command to update the capability database:</para> command to update the capability database:</para>
<screen>&prompt.root; <userinput>cap_mkdb /etc/login.conf</userinput></screen> <screen>&prompt.root; <userinput>cap_mkdb /etc/login.conf</userinput></screen>
<bridgehead renderas="sect4">Changing Login Classes with <sect4>
&man.vipw.8;</bridgehead> <title>Changing Login Classes with
&man.vipw.8;</title>
<indexterm> <indexterm>
<primary><command>vipw</command></primary> <primary><command>vipw</command></primary>
@ -348,9 +297,11 @@ me:\
language:</para> language:</para>
<programlisting>user:password:1111:11:<replaceable>language</replaceable>:0:0:User Name:/home/user:/bin/sh</programlisting> <programlisting>user:password:1111:11:<replaceable>language</replaceable>:0:0:User Name:/home/user:/bin/sh</programlisting>
</sect4>
<bridgehead renderas="sect4">Changing Login Classes with <sect4>
&man.adduser.8;</bridgehead> <title>Changing Login Classes with
&man.adduser.8;</title>
<indexterm> <indexterm>
<primary><command>adduser</command></primary> <primary><command>adduser</command></primary>
@ -386,9 +337,11 @@ me:\
<screen>&prompt.root; <userinput>adduser -class language</userinput></screen> <screen>&prompt.root; <userinput>adduser -class language</userinput></screen>
</listitem> </listitem>
</itemizedlist> </itemizedlist>
</sect4>
<bridgehead renderas="sect4">Changing Login Classes with <sect4>
&man.pw.8;</bridgehead> <title>Changing Login Classes with
&man.pw.8;</title>
<indexterm> <indexterm>
<primary><command>pw</command></primary> <primary><command>pw</command></primary>
</indexterm> </indexterm>
@ -396,10 +349,10 @@ me:\
it in this form:</para> it in this form:</para>
<screen>&prompt.root; <userinput>pw useradd user_name -L language</userinput></screen> <screen>&prompt.root; <userinput>pw useradd user_name -L language</userinput></screen>
</sect5>
</sect4> </sect4>
</sect3>
<sect4 xml:id="startup-file"> <sect3 xml:id="startup-file">
<title>Shell Startup File Method</title> <title>Shell Startup File Method</title>
<note> <note>
@ -439,7 +392,6 @@ me:\
<programlisting><envar>LANG=de_DE.ISO8859-1; export LANG</envar></programlisting> <programlisting><envar>LANG=de_DE.ISO8859-1; export LANG</envar></programlisting>
<programlisting><envar>setenv LANG de_DE.ISO8859-1</envar></programlisting> <programlisting><envar>setenv LANG de_DE.ISO8859-1</envar></programlisting>
</sect4>
</sect3> </sect3>
</sect2> </sect2>
@ -677,6 +629,46 @@ keychange="<replaceable>fkey_number sequence</replaceable>"</programlisting>
<sect1 xml:id="l10n-compiling"> <sect1 xml:id="l10n-compiling">
<title>Compiling <acronym>i18n</acronym> Programs</title> <title>Compiling <acronym>i18n</acronym> Programs</title>
<para>The &os;
<link xlink:href="&url.base;/ports/index.html">&os; Ports
Collection</link> contains programs which provide
application support for wide or multibyte characters for several languages.
Refer to the <acronym>i18n</acronym> documentation in the
respective &os; port
for more information on how to configure the application correctly or to
determine which compile options to use when building the
port.</para>
<para>Some things to keep in mind are:</para>
<itemizedlist>
<listitem>
<para>Language specific single C chars character sets
such as ISO8859-1, ISO8859-15, KOI8-R, and CP437. These
are described in &man.multibyte.3;.</para>
</listitem>
<listitem>
<para>Wide or multibyte encodings such as EUC and
Big5.</para>
</listitem>
</itemizedlist>
<para>The active list of character sets can be found at the
<link
xlink:href="http://www.iana.org/assignments/character-sets">IANA
Registry</link>.</para>
<note>
<para>&os; uses Xorg-compatible locale encodings
instead.</para>
</note>
<para>In the &os; Ports Collection, <acronym>i18n</acronym>
applications include <literal>i18n</literal> in their names
for easy identification. However, they do not always support
the language needed.</para>
<para>Many applications in the &os; Ports Collection have been <para>Many applications in the &os; Ports Collection have been
ported with <acronym>i18n</acronym> support. Some of these ported with <acronym>i18n</acronym> support. Some of these
include <literal>-i18n</literal> in the port name. These include <literal>-i18n</literal> in the port name. These