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

sysvinit
Last change on this file since a7e4965 was 22610fa, checked in by Chris Staub <chris@…>, 10 years ago

Update text on bash startup files/locales

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