source: chapter07/locale.xml@ 35a5259

10.0 10.0-rc1 10.1 10.1-rc1 11.0 11.0-rc1 11.0-rc2 11.0-rc3 11.1 11.1-rc1 11.2 11.2-rc1 11.3 11.3-rc1 12.0 12.0-rc1 12.1 12.1-rc1 8.0 8.1 8.2 8.3 8.4 9.0 9.1 arm bdubbs/gcc13 ml-11.0 multilib renodr/libudev-from-systemd s6-init trunk xry111/arm64 xry111/arm64-12.0 xry111/clfs-ng xry111/lfs-next xry111/loongarch xry111/loongarch-12.0 xry111/loongarch-12.1 xry111/mips64el xry111/pip3 xry111/rust-wip-20221008 xry111/update-glibc
Last change on this file since 35a5259 was 35a5259, checked in by Bruce Dubbs <bdubbs@…>, 8 years ago

Optimize building merged books

git-svn-id: http://svn.linuxfromscratch.org/LFS/branches/merge@11076 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689

  • Property mode set to 100644
File size: 7.6 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" revision="systemd">
9 <?dbhtml filename="locale.html"?>
10
11 <title>Configuring the System Locale</title>
12
13 <indexterm zone="ch-scripts-locale">
14 <primary sortas="e-etc-locale-conf">/etc/locale.conf</primary>
15 </indexterm>
16
17 <para>The <filename>/etc/locale.conf</filename> below sets some
18 environment variables necessary for native language support. Setting
19 them 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 other
27 classes. This is necessary for <command>bash</command> to properly accept
28 non-ASCII characters in command lines in non-English 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>Replace <replaceable>&lt;ll&gt;</replaceable> below with the two-letter code
42 for the desired language (e.g., <quote>en</quote>) and
43 <replaceable>&lt;CC&gt;</replaceable> with the two-letter code for the appropriate
44 country (e.g., <quote>GB</quote>). <replaceable>&lt;charmap&gt;</replaceable> should
45 be replaced with the canonical charmap for your chosen locale. Optional
46 modifiers such as <quote>@euro</quote> may also be present.</para>
47
48 <para>The list of all locales supported by Glibc can be obtained by running
49 the following command:</para>
50
51<screen role="nodump"><userinput>locale -a</userinput></screen>
52
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>.
55 Some applications cannot handle the various synonyms correctly (e.g., require
56 that <quote>UTF-8</quote> is written as <quote>UTF-8</quote>, not
57 <quote>utf8</quote>), so it is safest in most
58 cases to choose the canonical name for a particular locale. To determine
59 the canonical name, run the following command, where <replaceable>&lt;locale
60 name&gt;</replaceable> is the output given by <command>locale -a</command> for
61 your preferred locale (<quote>en_GB.iso88591</quote> in our example).</para>
62
63<screen role="nodump"><userinput>LC_ALL=<replaceable>&lt;locale name&gt;</replaceable> locale charmap</userinput></screen>
64
65 <para>For the <quote>en_GB.iso88591</quote> locale, the above command
66 will print:</para>
67
68<screen><computeroutput>ISO-8859-1</computeroutput></screen>
69
70 <para>This results in a final locale setting of <quote>en_GB.ISO-8859-1</quote>.
71 It is important that the locale found using the heuristic above is tested prior
72 to it being added to the Bash startup files:</para>
73
74<screen role="nodump"><userinput>LC_ALL=&lt;locale name&gt; locale language
75LC_ALL=&lt;locale name&gt; locale charmap
76LC_ALL=&lt;locale name&gt; locale int_curr_symbol
77LC_ALL=&lt;locale name&gt; 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 6 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 the
89 <command>localedef</command> command, or consider choosing a different locale.
90 Further instructions assume that there are no such error messages from
91 Glibc.</para>
92
93 <!-- FIXME: the xlib example will became obsolete real soon -->
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
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/locale.conf</filename> file:</para>
116
117<screen><userinput>cat &gt; /etc/locale.conf &lt;&lt; "EOF"
118<literal>LANG=<replaceable>&lt;ll&gt;_&lt;CC&gt;.&lt;charmap&gt;&lt;@modifiers&gt;</replaceable></literal>
119EOF</userinput></screen>
120
121 <para>Note that you can modify <filename>/etc/locale.conf</filename> with
122 systemd <command>localectl</command> utility. To use <command>localectl</command>
123 for the example above, run:</para>
124
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>
126
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>
132
133<screen role="nodump"><userinput>localectl set-locale LANG="en_US.UTF-8" LC_CTYPE="en_US"</userinput></screen>
134
135 <note><para>Please note that <command>localectl</command> command can
136 be used only on a system booted with systemd.</para></note>
137
138 <para>The <quote>C</quote> (default) and <quote>en_US</quote> (the recommended
139 one for United States English users) locales are different. <quote>C</quote>
140 uses the US-ASCII 7-bit character set, and treats bytes with the high bit set
141 as invalid characters. That's why, e.g., the <command>ls</command> command
142 substitutes them with question marks in that locale. Also, an attempt to send
143 mail with such characters from Mutt or Pine results in non-RFC-conforming
144 messages being sent (the charset in the outgoing mail is indicated as <quote>unknown
145 8-bit</quote>). So you can use the <quote>C</quote> locale only if you are sure that
146 you will never need 8-bit characters.</para>
147
148 <para>UTF-8 based locales are not supported well by many programs.
149 Work is in progress to document and, if possible, fix such problems, see
150 <ulink url="&blfs-book;introduction/locale-issues.html"/>.</para>
151
152</sect1>
Note: See TracBrowser for help on using the repository browser.