source: BOOK/system-config/common/locale.xml @ 0131d1b

Last change on this file since 0131d1b was 0131d1b, checked in by Chris Staub <chris@…>, 10 years ago

More consistent capitalization for systemd

  • Property mode set to 100644
File size: 7.0 KB
1<?xml version="1.0" encoding="ISO-8859-1"?>
2<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3  "" [
4  <!ENTITY % general-entities SYSTEM "../../general.ent">
5  %general-entities;
8<sect1 id="ch-scripts-locale">
9  <title>Setting Up Locale Information</title>
10  <?dbhtml filename="locale.html"?>
12  <indexterm zone="ch-scripts-locale">
13    <primary sortas="e-/etc/locale.conf">/etc/locale.conf</primary>
14  </indexterm>
16  <para>The <filename>/etc/locale.conf</filename> below sets some environment
17  variables necessary for native language support. Setting them properly
18  results in:</para>
20  <itemizedlist>
21    <listitem>
22      <para>The output of programs translated into the native language</para>
23    </listitem>
24    <listitem>
25      <para>Correct classification of characters into letters, digits and other
26      classes. This is necessary for <command>bash</command> to properly accept
27      non-ASCII characters in command lines in non-English locales</para>
28    </listitem>
29    <listitem>
30      <para>The correct alphabetical sorting order for the country</para>
31    </listitem>
32    <listitem>
33      <para>Appropriate default paper size</para>
34    </listitem>
35    <listitem>
36      <para>Correct formatting of monetary, time, and date values</para>
37    </listitem>
38  </itemizedlist>
40  <para>Replace <replaceable>[ll]</replaceable> below with the
41  two-letter code for the desired language (e.g., <quote>en</quote>) and
42  <replaceable>[CC]</replaceable> with the two-letter code for the
43  appropriate country (e.g., <quote>GB</quote> or <quote>US</quote>).
44  <replaceable>[charmap]</replaceable> should be replaced with the
45  canonical charmap for your chosen locale. Optional modifiers such as
46  <quote>@euro</quote> may also be present.</para>
48  <para>The list of all locales supported by Glibc can be obtained by running
49  the following command:</para>
51<screen role="nodump"><userinput>locale -a</userinput></screen>
53  <para>Locales can have a number of synonyms, e.g. <quote>ISO-8859-1</quote>
54  is also referred to as <quote>iso8859-1</quote> and <quote>iso88591</quote>.
55  Some applications cannot handle the various synonyms correctly, so it is
56  safest to choose the canonical name for a particular locale. To determine
57  the canonical name, run the following command, where <replaceable>[locale
58  name]</replaceable> is the output given by <command>locale -a</command> for
59  your preferred locale (<quote>en_US.utf8</quote> in our example).</para>
61<screen role="nodump"><userinput>LC_ALL=<replaceable>[locale name]</replaceable> locale charmap</userinput></screen>
63  <para>For the <quote>en_US.utf8</quote> locale, the above command
64  will print:</para>
68  <para>This results in a final locale setting of <quote>en_US.UTF-8</quote>.
69  It is important that the locale found using the heuristic above is tested
70  prior to it being added to <filename>/etc/locale.conf</filename>:</para>
72<screen role="nodump"><userinput>LC_ALL=[locale name] locale territory
73LC_ALL=[locale name] locale language
74LC_ALL=[locale name] locale charmap
75LC_ALL=[locale name] locale int_curr_symbol
76LC_ALL=[locale name] locale int_prefix</userinput></screen>
78  <para>The above commands should print the language name, the character
79  encoding used by the locale, the local currency, and the prefix to dial
80  before the telephone number in order to get into the country. If any of the
81  commands above fail with a message similar to the one shown below, this means
82  that your locale was either not installed in Chapter 10 or is not supported by
83  the default installation of Glibc.</para>
85<screen><computeroutput>locale: Cannot set LC_* to default locale: No such file or directory</computeroutput></screen>
87  <para>If this happens, you should either install the desired locale using
88  the <command>localedef</command> command, or consider choosing a different
89  locale. Further instructions assume that there are no such error messages
90  from Glibc.</para>
92  <para>Some packages beyond CLFS may also lack support for your chosen locale.
93  One example is the X library (part of the X Window System), which outputs
94  the following error message:</para>
96<screen><computeroutput>Warning: locale not supported by Xlib, locale set to C</computeroutput></screen>
98  <para>Sometimes it is possible to fix this by removing the charmap part of
99  the locale specification, as long as that does not change the character map
100  that Glibc associates with the locale (this can be checked by running the
101  <command>locale charmap</command> command in both locales). For example,
102  one would have to change &quot;de_DE.ISO-8859-15@euro&quot; to
103  &quot;de_DE@euro&quot; in order to get this locale recognized by Xlib.</para>
105  <para>Other packages can also function incorrectly (but may not necessarily
106  display any error messages) if the locale name does not meet their
107  expectations. In those cases, investigating how other Linux distributions
108  support your locale might provide some useful information.</para>
110  <para>Once the proper locale settings have been determined, create the
111  <filename>/etc/locale.conf</filename> file:</para>
113<screen><userinput>cat &gt; /etc/locale.conf &lt;&lt; "EOF"
114<literal># Begin /etc/locale.conf
118# End /etc/locale.conf</literal>
121  <para>Note that you can modify <filename>/etc/locale.conf</filename> with
122  systemd's <command>localectl</command> utility. To use
123  <command>localectl</command> for the example above, run:</para>
125<screen role="nodump"><userinput>localectl set-locale LANG="<replaceable>[ll]_[CC][charmap][@modifiers]</replaceable>"</userinput></screen>
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
131  en_US.UTF-8 but <envar>LC_CTYPE</envar> is set as just en_US is:</para>
133<screen role="nodump"><userinput>localectl set-locale LANG="en_US.UTF-8" LC_CTYPE="en_US"</userinput></screen>
135  <note><para>Please note that <command>localectl</command> command can
136  be used  only on a system booted with systemd.</para></note>
137  <para>Setting the keyboard layout, screen font, and locale-related
138  environment variables are the only internationalization steps needed to
139  support locales that use ordinary single-byte encodings and left-to-right
140  writing direction. UTF-8 has been tested on the English, French, German,
141  Italian, and Spanish locales. All other locales are untested. If you discover
142  issues with any other locale please open a ticket in our Trac system.</para>
144  <para>Some locales need additional programs and support. CLFS will not be
145  supporting these locales in the book. We welcome the support for these other
146  locales via <ulink url="&cblfs-root;"/>.</para>
Note: See TracBrowser for help on using the repository browser.