Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • chapter09/locale.xml

    r4ecfc55 r4f560248  
    1 <?xml version="1.0" encoding="UTF-8"?>
     1<?xml version="1.0" encoding="ISO-8859-1"?>
    22<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
    33  "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
     
    66]>
    77
    8 <sect1 id="ch-config-locale">
     8<sect1 id="ch-config-locale" revision="systemd">
    99  <?dbhtml filename="locale.html"?>
    1010
     
    1212
    1313  <indexterm zone="ch-config-locale">
    14     <primary sortas="e-/etc/profile">/etc/profile</primary>
     14    <primary sortas="e-etc-locale-conf">/etc/locale.conf</primary>
    1515  </indexterm>
    1616
    17   <indexterm zone="ch-config-locale" revision='systemd'>
    18     <primary sortas="e-/etc/profile">/etc/locale.conf</primary>
    19   </indexterm>
    20 
    21   <para>Some environment variables are necessary for native language
    22   support. Setting them properly results in:</para>
     17  <para>The <filename>/etc/locale.conf</filename> file below sets some
     18  environment variables necessary for native language support. Setting
     19  them properly results in:</para>
    2320
    2421  <itemizedlist>
     
    4340
    4441  <para>Replace <replaceable>&lt;ll&gt;</replaceable> below with the two-letter code
    45   for your desired language (e.g., <literal>en</literal>) and
     42  for your desired language (e.g., <quote>en</quote>) and
    4643  <replaceable>&lt;CC&gt;</replaceable> with the two-letter code for the appropriate
    47   country (e.g., <literal>GB</literal>). <replaceable>&lt;charmap&gt;</replaceable> should
     44  country (e.g., <quote>GB</quote>). <replaceable>&lt;charmap&gt;</replaceable> should
    4845  be replaced with the canonical charmap for your chosen locale. Optional
    49   modifiers such as <literal>@euro</literal> may also be present.</para>
     46  modifiers such as <quote>@euro</quote> may also be present.</para>
    5047
    5148  <para>The list of all locales supported by Glibc can be obtained by running
     
    5451<screen role="nodump"><userinput>locale -a</userinput></screen>
    5552
    56   <para>Charmaps can have a number of aliases, e.g.,
    57   <literal>ISO-8859-1</literal> is also referred to as
    58   <literal>iso8859-1</literal> and <literal>iso88591</literal>.
     53  <para>Charmaps can have a number of aliases, e.g., <quote>ISO-8859-1</quote>
     54  is also referred to as <quote>iso8859-1</quote> and <quote>iso88591</quote>.
    5955  Some applications cannot handle the various synonyms correctly (e.g., require
    60   that <literal>UTF-8</literal> is written as <literal>UTF-8</literal>, not
    61   <literal>utf8</literal>), so it is the safest in most
     56  that <quote>UTF-8</quote> is written as <quote>UTF-8</quote>, not
     57  <quote>utf8</quote>), so it is the safest in most
    6258  cases to choose the canonical name for a particular locale. To determine
    6359  the canonical name, run the following command, where <replaceable>&lt;locale
    6460  name&gt;</replaceable> is the output given by <command>locale -a</command> for
    65   your preferred locale (<literal>en_GB.iso88591</literal> in our
    66   example).</para>
     61  your preferred locale (<quote>en_GB.iso88591</quote> in our example).</para>
    6762
    6863<screen role="nodump"><userinput>LC_ALL=<replaceable>&lt;locale name&gt;</replaceable> locale charmap</userinput></screen>
    6964
    70   <para>For the <literal>en_GB.iso88591</literal> locale, the above command
     65  <para>For the <quote>en_GB.iso88591</quote> locale, the above command
    7166  will print:</para>
    7267
    7368<screen><computeroutput>ISO-8859-1</computeroutput></screen>
    7469
    75   <para>This results in a final locale setting of <literal>en_GB.ISO-8859-1</literal>.
     70  <para>This results in a final locale setting of <quote>en_GB.ISO-8859-1</quote>.
    7671  It is important that the locale found using the heuristic above is tested prior
    7772  to it being added to the Bash startup files:</para>
     
    9691  Glibc.</para>
    9792
     93  <!-- FIXME: the xlib example will become obsolete in the future.-->
     94  <para>Some packages beyond LFS may also lack support for your chosen locale. One
     95  example is the X library (part of the X Window System), which outputs the
     96  following error message if the locale does not exactly match one of the character
     97  map names in its internal files:</para>
     98
     99<screen><computeroutput>Warning: locale not supported by Xlib, locale set to C</computeroutput></screen>
     100
     101  <para>In several cases Xlib expects that the character map will be listed in
     102  uppercase notation with canonical dashes. For instance, "ISO-8859-1" rather
     103  than "iso88591". It is also  possible to find an appropriate specification by
     104  removing the charmap part of the locale specification.  This can be checked
     105  by running the <command>locale charmap</command> command in both locales.
     106  For example, one would have to change "de_DE.ISO-8859-15@euro" to
     107  "de_DE@euro" in order to get this locale recognized by Xlib.</para>
     108
    98109  <para>Other packages can also function incorrectly (but may not necessarily
    99110  display any error messages) if the locale name does not meet their expectations.
     
    101112  might provide some useful information.</para>
    102113
    103   <para revision='systemd'>Once the proper locale settings have been
    104   determined, create the <filename>/etc/locale.conf</filename> file:</para>
     114  <para>Once the proper locale settings have been determined, create the
     115  <filename>/etc/locale.conf</filename> file:</para>
    105116
    106 <screen revision='systemd'><userinput>cat &gt; /etc/locale.conf &lt;&lt; "EOF"
     117<screen><userinput>cat &gt; /etc/locale.conf &lt;&lt; "EOF"
    107118<literal>LANG=<replaceable>&lt;ll&gt;_&lt;CC&gt;.&lt;charmap&gt;&lt;@modifiers&gt;</replaceable></literal>
    108119EOF</userinput></screen>
    109120
    110   <para>The shell program <command>/bin/bash</command> (here after referred
    111   as <quote>the shell</quote>) uses a collection of startup files to help
    112   create the environment to run in. Each file has a specific use and may
    113   affect login and interactive environments differently. The files in the
    114   <filename class="directory">/etc</filename> directory provide global
    115   settings.  If equivalent files exist in the home directory, they
    116   may override the global settings.</para>
    117 
    118   <para>An interactive login shell is started after a successful login,
    119   using <command>/bin/login</command>, by reading the
    120   <filename>/etc/passwd</filename> file.  An interactive non-login shell is
    121   started at the command-line (e.g.
    122   <prompt>[prompt]$</prompt><command>/bin/bash</command>).  A
    123   non-interactive shell is usually present when a shell script is running.
    124   It is non-interactive because it is processing a script and not waiting
    125   for user input between commands.</para>
    126 
    127   <para><phrase revision='systemd'>The login shells are often unaffected by
    128   the settings in <filename>/etc/locale.conf</filename>. </phrase>Create the
    129   <filename>/etc/profile</filename>
    130   <phrase revision='sysv'>once the proper locale settings have been
    131   determined to set the desired locale</phrase><phrase
    132   revision='systemd'>to read the locale settings from
    133   <filename>/etc/locale.conf</filename> and export them</phrase>,
    134   but set the <literal>C.UTF-8</literal> locale instead if running in the Linux
    135   console (to prevent programs from outputting characters that the Linux
    136   console is unable to render):</para>
    137 
    138 <screen revision="systemd"><userinput>cat &gt; /etc/profile &lt;&lt; "EOF"
    139 <literal># Begin /etc/profile
    140 
    141 for i in $(locale); do
    142   unset ${i%=*}
    143 done
    144 
    145 if [[ "$TERM" = linux ]]; then
    146   export LANG=C.UTF-8
    147 else
    148   source /etc/locale.conf
    149 
    150   for i in $(locale); do
    151     key=${i%=*}
    152     if [[ -v $key ]]; then
    153       export $key
    154     fi
    155   done
    156 fi
    157 
    158 # End /etc/profile</literal>
    159 EOF</userinput></screen>
    160 
    161 <screen revision="sysv"><userinput>cat &gt; /etc/profile &lt;&lt; "EOF"
    162 <literal># Begin /etc/profile
    163 
    164 for i in $(locale); do
    165   unset ${i%=*}
    166 done
    167 
    168 if [[ "$TERM" = linux ]]; then
    169   export LANG=C.UTF-8
    170 else
    171   export LANG=<replaceable>&lt;ll&gt;_&lt;CC&gt;.&lt;charmap&gt;&lt;@modifiers&gt;</replaceable>
    172 fi
    173 
    174 # End /etc/profile</literal>
    175 EOF</userinput></screen>
    176 
    177   <para revision='systemd'>Note that you can modify <filename>/etc/locale.conf</filename> with the
     121  <para>Note that you can modify <filename>/etc/locale.conf</filename> with the
    178122  systemd <command>localectl</command> utility. To use
    179123  <command>localectl</command> for the example above, run:</para>
    180124
    181 <screen revision='systemd' role="nodump"><userinput>localectl set-locale LANG="<replaceable>&lt;ll&gt;_&lt;CC&gt;.&lt;charmap&gt;&lt;@modifiers&gt;</replaceable>"</userinput></screen>
     125<screen role="nodump"><userinput>localectl set-locale LANG="<replaceable>&lt;ll&gt;_&lt;CC&gt;.&lt;charmap&gt;&lt;@modifiers&gt;</replaceable>"</userinput></screen>
    182126
    183   <para revision='systemd'>You can also specify other language specific
    184   environment variables such as <envar>LANG</envar>,
    185   <envar>LC_CTYPE</envar>, <envar>LC_NUMERIC</envar> or any other
    186   environment variable from <command>locale</command> output. Just separate
    187   them with a space. An example where <envar>LANG</envar> is set as
     127  <para>You can also specify other language specific environment variables such
     128  as <envar>LANG</envar>, <envar>LC_CTYPE</envar>, <envar>LC_NUMERIC</envar> or
     129  any other environment variable from <command>locale</command> output. Just
     130  separate them with a space. An example where <envar>LANG</envar> is set as
    188131  en_US.UTF-8 but <envar>LC_CTYPE</envar> is set as just en_US is:</para>
    189132
    190 <screen revision='systemd' role="nodump"><userinput>localectl set-locale LANG="en_US.UTF-8" LC_CTYPE="en_US"</userinput></screen>
     133<screen role="nodump"><userinput>localectl set-locale LANG="en_US.UTF-8" LC_CTYPE="en_US"</userinput></screen>
    191134
    192   <note revision='systemd'><para>Please note that the
    193   <command>localectl</command> command doesn't work in the chroot
    194   environment.  It can only be used after the LFS system is booted with
    195   systemd.</para></note>
     135  <note><para>Please note that the <command>localectl</command> command
     136  doesn't work in the chroot environment.  It can only
     137  be used after the LFS system is booted with systemd.</para></note>
    196138
    197   <para>The <literal>C</literal> (default) and <literal>en_US</literal>
    198   (the recommended one for United States English users) locales are
    199   different. <literal>C</literal>
     139  <para>The <quote>C</quote> (default) and <quote>en_US</quote> (the recommended
     140  one for United States English users) locales are different. <quote>C</quote>
    200141  uses the US-ASCII 7-bit character set, and treats bytes with the high bit set
    201142  as invalid characters. That's why, e.g., the <command>ls</command> command
    202143  substitutes them with question marks in that locale. Also, an attempt to send
    203144  mail with such characters from Mutt or Pine results in non-RFC-conforming
    204   messages being sent (the charset in the outgoing mail is indicated as
    205   <computeroutput>unknown 8-bit</computeroutput>). It's suggested that you
    206   use the <literal>C</literal> locale only
     145  messages being sent (the charset in the outgoing mail is indicated as <quote>unknown
     146  8-bit</quote>). It's suggested that you use the <quote>C</quote> locale only
    207147  if you are certain that you will never need 8-bit characters.</para>
    208148
     149<!--
     150  <para>UTF-8 based locales are not supported well by many programs.
     151  Work is in progress to document and, if possible, fix such problems, see
     152  <ulink url="&blfs-book;introduction/locale-issues.html"/>.</para>
     153-->
     154
    209155</sect1>
Note: See TracChangeset for help on using the changeset viewer.