source: BOOK/bootscripts/common/locale.xml@ c822ddc

clfs-1.2 clfs-2.1 clfs-3.0.0-systemd clfs-3.0.0-sysvinit systemd sysvinit
Last change on this file since c822ddc was 73e1db21, checked in by Chris Staub <chris@…>, 16 years ago

Reorder bootscripts section and split Bash Shell Startup Files page

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