source: chapter09/locale.xml@ 0d80918a

12.1 12.1-rc1 12.2 12.2-rc1 multilib trunk xry111/arm64 xry111/clfs-ng xry111/loongarch xry111/loongarch-12.1 xry111/loongarch-12.2 xry111/mips64el xry111/multilib xry111/update-glibc
Last change on this file since 0d80918a was 360fdfca, checked in by Pierre Labastie <pierre.labastie@…>, 8 months ago

Fix punctuation in quotes, and quote signs

  • period and comma inside quotes
  • " to <quote>
  • some " to <literal> when it is a var value
  • Property mode set to 100644
File size: 6.7 KB
Line 
1<?xml version="1.0" encoding="UTF-8"?>
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" revision="systemd">
9 <?dbhtml filename="locale.html"?>
10
11 <title>Configuring the System Locale</title>
12
13 <indexterm zone="ch-config-locale">
14 <primary sortas="e-etc-locale-conf">/etc/locale.conf</primary>
15 </indexterm>
16
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>
20
21 <itemizedlist>
22 <listitem>
23 <para>The output of programs being translated into your native language</para>
24 </listitem>
25 <listitem>
26 <para>The 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>The appropriate default paper size</para>
35 </listitem>
36 <listitem>
37 <para>The 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 your desired language (e.g., <literal>en</literal>) and
43 <replaceable>&lt;CC&gt;</replaceable> with the two-letter code for the appropriate
44 country (e.g., <literal>GB</literal>). <replaceable>&lt;charmap&gt;</replaceable> should
45 be replaced with the canonical charmap for your chosen locale. Optional
46 modifiers such as <literal>@euro</literal> 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 <literal>UTF-8,</literal> not
57 <literal>utf8</literal>), so it is the 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 <literal>en_GB.ISO-8859-1</literal>.
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&nbsp;8 or is not
84 supported by 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 <para>Other packages can also function incorrectly (but may not necessarily
94 display any error messages) if the locale name does not meet their expectations.
95 In those cases, investigating how other Linux distributions support your locale
96 might provide some useful information.</para>
97
98 <para>Once the proper locale settings have been determined, create the
99 <filename>/etc/locale.conf</filename> file:</para>
100
101<screen><userinput>cat &gt; /etc/locale.conf &lt;&lt; "EOF"
102<literal>LANG=<replaceable>&lt;ll&gt;_&lt;CC&gt;.&lt;charmap&gt;&lt;@modifiers&gt;</replaceable></literal>
103EOF</userinput></screen>
104
105 <para>Note that you can modify <filename>/etc/locale.conf</filename> with the
106 systemd <command>localectl</command> utility. To use
107 <command>localectl</command> for the example above, run:</para>
108
109<screen role="nodump"><userinput>localectl set-locale LANG="<replaceable>&lt;ll&gt;_&lt;CC&gt;.&lt;charmap&gt;&lt;@modifiers&gt;</replaceable>"</userinput></screen>
110
111 <para>You can also specify other language specific environment variables such
112 as <envar>LANG</envar>, <envar>LC_CTYPE</envar>, <envar>LC_NUMERIC</envar> or
113 any other environment variable from <command>locale</command> output. Just
114 separate them with a space. An example where <envar>LANG</envar> is set as
115 en_US.UTF-8 but <envar>LC_CTYPE</envar> is set as just en_US is:</para>
116
117<screen role="nodump"><userinput>localectl set-locale LANG="en_US.UTF-8" LC_CTYPE="en_US"</userinput></screen>
118
119 <note><para>Please note that the <command>localectl</command> command
120 doesn't work in the chroot environment. It can only
121 be used after the LFS system is booted with systemd.</para></note>
122
123 <para>The <quote>C</quote> (default) and <quote>en_US</quote> (the recommended
124 one for United States English users) locales are different. <quote>C</quote>
125 uses the US-ASCII 7-bit character set, and treats bytes with the high bit set
126 as invalid characters. That's why, e.g., the <command>ls</command> command
127 substitutes them with question marks in that locale. Also, an attempt to send
128 mail with such characters from Mutt or Pine results in non-RFC-conforming
129 messages being sent (the charset in the outgoing mail is indicated as <quote>unknown
130 8-bit</quote>). It's suggested that you use the <quote>C</quote> locale only
131 if you are certain that you will never need 8-bit characters.</para>
132
133<!--
134 <para>UTF-8 based locales are not supported well by many programs.
135 Work is in progress to document and, if possible, fix such problems, see
136 <ulink url="&blfs-book;introduction/locale-issues.html"/>.</para>
137-->
138
139</sect1>
Note: See TracBrowser for help on using the repository browser.