Changes in chapter09/locale.xml [4f560248:4ecfc55]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
chapter09/locale.xml
r4f560248 r4ecfc55 1 <?xml version="1.0" encoding=" ISO-8859-1"?>1 <?xml version="1.0" encoding="UTF-8"?> 2 2 <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" 3 3 "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [ … … 6 6 ]> 7 7 8 <sect1 id="ch-config-locale" revision="systemd">8 <sect1 id="ch-config-locale"> 9 9 <?dbhtml filename="locale.html"?> 10 10 … … 12 12 13 13 <indexterm zone="ch-config-locale"> 14 <primary sortas="e- etc-locale-conf">/etc/locale.conf</primary>14 <primary sortas="e-/etc/profile">/etc/profile</primary> 15 15 </indexterm> 16 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> 17 <indexterm zone="ch-config-locale" revision='systemd'> 18 <primary sortas="e-/etc/profile">/etc/locale.conf</primary> 19 </indexterm> 20 21 <para>Some environment variables are necessary for native language 22 support. Setting them properly results in:</para> 20 23 21 24 <itemizedlist> … … 40 43 41 44 <para>Replace <replaceable><ll></replaceable> below with the two-letter code 42 for your desired language (e.g., < quote>en</quote>) and45 for your desired language (e.g., <literal>en</literal>) and 43 46 <replaceable><CC></replaceable> with the two-letter code for the appropriate 44 country (e.g., < quote>GB</quote>). <replaceable><charmap></replaceable> should47 country (e.g., <literal>GB</literal>). <replaceable><charmap></replaceable> should 45 48 be replaced with the canonical charmap for your chosen locale. Optional 46 modifiers such as < quote>@euro</quote> may also be present.</para>49 modifiers such as <literal>@euro</literal> may also be present.</para> 47 50 48 51 <para>The list of all locales supported by Glibc can be obtained by running … … 51 54 <screen role="nodump"><userinput>locale -a</userinput></screen> 52 55 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>. 56 <para>Charmaps can have a number of aliases, e.g., 57 <literal>ISO-8859-1</literal> is also referred to as 58 <literal>iso8859-1</literal> and <literal>iso88591</literal>. 55 59 Some applications cannot handle the various synonyms correctly (e.g., require 56 that < quote>UTF-8</quote> is written as <quote>UTF-8</quote>, not57 < quote>utf8</quote>), so it is the safest in most60 that <literal>UTF-8</literal> is written as <literal>UTF-8</literal>, not 61 <literal>utf8</literal>), so it is the safest in most 58 62 cases to choose the canonical name for a particular locale. To determine 59 63 the canonical name, run the following command, where <replaceable><locale 60 64 name></replaceable> is the output given by <command>locale -a</command> for 61 your preferred locale (<quote>en_GB.iso88591</quote> in our example).</para> 65 your preferred locale (<literal>en_GB.iso88591</literal> in our 66 example).</para> 62 67 63 68 <screen role="nodump"><userinput>LC_ALL=<replaceable><locale name></replaceable> locale charmap</userinput></screen> 64 69 65 <para>For the < quote>en_GB.iso88591</quote> locale, the above command70 <para>For the <literal>en_GB.iso88591</literal> locale, the above command 66 71 will print:</para> 67 72 68 73 <screen><computeroutput>ISO-8859-1</computeroutput></screen> 69 74 70 <para>This results in a final locale setting of < quote>en_GB.ISO-8859-1</quote>.75 <para>This results in a final locale setting of <literal>en_GB.ISO-8859-1</literal>. 71 76 It is important that the locale found using the heuristic above is tested prior 72 77 to it being added to the Bash startup files:</para> … … 91 96 Glibc.</para> 92 97 93 <!-- FIXME: the xlib example will become obsolete in the future.-->94 <para>Some packages beyond LFS may also lack support for your chosen locale. One95 example is the X library (part of the X Window System), which outputs the96 following error message if the locale does not exactly match one of the character97 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 in102 uppercase notation with canonical dashes. For instance, "ISO-8859-1" rather103 than "iso88591". It is also possible to find an appropriate specification by104 removing the charmap part of the locale specification. This can be checked105 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" to107 "de_DE@euro" in order to get this locale recognized by Xlib.</para>108 109 98 <para>Other packages can also function incorrectly (but may not necessarily 110 99 display any error messages) if the locale name does not meet their expectations. … … 112 101 might provide some useful information.</para> 113 102 114 <para >Once the proper locale settings have been determined, create the115 <filename>/etc/locale.conf</filename> file:</para>116 117 <screen ><userinput>cat > /etc/locale.conf << "EOF"103 <para revision='systemd'>Once the proper locale settings have been 104 determined, create the <filename>/etc/locale.conf</filename> file:</para> 105 106 <screen revision='systemd'><userinput>cat > /etc/locale.conf << "EOF" 118 107 <literal>LANG=<replaceable><ll>_<CC>.<charmap><@modifiers></replaceable></literal> 119 108 EOF</userinput></screen> 120 109 121 <para>Note that you can modify <filename>/etc/locale.conf</filename> with the 110 <para>The shell program <command>/bin/bash</command> (here after referred 111 as <quote>the shell</quote>) uses a collection of startup files to help 112 create the environment to run in. Each file has a specific use and may 113 affect login and interactive environments differently. The files in the 114 <filename class="directory">/etc</filename> directory provide global 115 settings. If equivalent files exist in the home directory, they 116 may override the global settings.</para> 117 118 <para>An interactive login shell is started after a successful login, 119 using <command>/bin/login</command>, by reading the 120 <filename>/etc/passwd</filename> file. An interactive non-login shell is 121 started at the command-line (e.g. 122 <prompt>[prompt]$</prompt><command>/bin/bash</command>). A 123 non-interactive shell is usually present when a shell script is running. 124 It is non-interactive because it is processing a script and not waiting 125 for user input between commands.</para> 126 127 <para><phrase revision='systemd'>The login shells are often unaffected by 128 the settings in <filename>/etc/locale.conf</filename>. </phrase>Create the 129 <filename>/etc/profile</filename> 130 <phrase revision='sysv'>once the proper locale settings have been 131 determined to set the desired locale</phrase><phrase 132 revision='systemd'>to read the locale settings from 133 <filename>/etc/locale.conf</filename> and export them</phrase>, 134 but set the <literal>C.UTF-8</literal> locale instead if running in the Linux 135 console (to prevent programs from outputting characters that the Linux 136 console is unable to render):</para> 137 138 <screen revision="systemd"><userinput>cat > /etc/profile << "EOF" 139 <literal># Begin /etc/profile 140 141 for i in $(locale); do 142 unset ${i%=*} 143 done 144 145 if [[ "$TERM" = linux ]]; then 146 export LANG=C.UTF-8 147 else 148 source /etc/locale.conf 149 150 for i in $(locale); do 151 key=${i%=*} 152 if [[ -v $key ]]; then 153 export $key 154 fi 155 done 156 fi 157 158 # End /etc/profile</literal> 159 EOF</userinput></screen> 160 161 <screen revision="sysv"><userinput>cat > /etc/profile << "EOF" 162 <literal># Begin /etc/profile 163 164 for i in $(locale); do 165 unset ${i%=*} 166 done 167 168 if [[ "$TERM" = linux ]]; then 169 export LANG=C.UTF-8 170 else 171 export LANG=<replaceable><ll>_<CC>.<charmap><@modifiers></replaceable> 172 fi 173 174 # End /etc/profile</literal> 175 EOF</userinput></screen> 176 177 <para revision='systemd'>Note that you can modify <filename>/etc/locale.conf</filename> with the 122 178 systemd <command>localectl</command> utility. To use 123 179 <command>localectl</command> for the example above, run:</para> 124 180 125 <screen role="nodump"><userinput>localectl set-locale LANG="<replaceable><ll>_<CC>.<charmap><@modifiers></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 181 <screen revision='systemd' role="nodump"><userinput>localectl set-locale LANG="<replaceable><ll>_<CC>.<charmap><@modifiers></replaceable>"</userinput></screen> 182 183 <para revision='systemd'>You can also specify other language specific 184 environment variables such as <envar>LANG</envar>, 185 <envar>LC_CTYPE</envar>, <envar>LC_NUMERIC</envar> or any other 186 environment variable from <command>locale</command> output. Just separate 187 them with a space. An example where <envar>LANG</envar> is set as 131 188 en_US.UTF-8 but <envar>LC_CTYPE</envar> is set as just en_US is:</para> 132 189 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 the <command>localectl</command> command 136 doesn't work in the chroot environment. It can only 137 be used after the LFS system is booted with systemd.</para></note> 138 139 <para>The <quote>C</quote> (default) and <quote>en_US</quote> (the recommended 140 one for United States English users) locales are different. <quote>C</quote> 190 <screen revision='systemd' role="nodump"><userinput>localectl set-locale LANG="en_US.UTF-8" LC_CTYPE="en_US"</userinput></screen> 191 192 <note revision='systemd'><para>Please note that the 193 <command>localectl</command> command doesn't work in the chroot 194 environment. It can only be used after the LFS system is booted with 195 systemd.</para></note> 196 197 <para>The <literal>C</literal> (default) and <literal>en_US</literal> 198 (the recommended one for United States English users) locales are 199 different. <literal>C</literal> 141 200 uses the US-ASCII 7-bit character set, and treats bytes with the high bit set 142 201 as invalid characters. That's why, e.g., the <command>ls</command> command 143 202 substitutes them with question marks in that locale. Also, an attempt to send 144 203 mail with such characters from Mutt or Pine results in non-RFC-conforming 145 messages being sent (the charset in the outgoing mail is indicated as <quote>unknown 146 8-bit</quote>). It's suggested that you use the <quote>C</quote> locale only 204 messages being sent (the charset in the outgoing mail is indicated as 205 <computeroutput>unknown 8-bit</computeroutput>). It's suggested that you 206 use the <literal>C</literal> locale only 147 207 if you are certain that you will never need 8-bit characters.</para> 148 208 149 <!--150 <para>UTF-8 based locales are not supported well by many programs.151 Work is in progress to document and, if possible, fix such problems, see152 <ulink url="&blfs-book;introduction/locale-issues.html"/>.</para>153 -->154 155 209 </sect1>
Note:
See TracChangeset
for help on using the changeset viewer.