Changes in chapter09/locale.xml [4ecfc55:4f560248]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
chapter09/locale.xml
r4ecfc55 r4f560248 1 <?xml version="1.0" encoding=" UTF-8"?>1 <?xml version="1.0" encoding="ISO-8859-1"?> 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" >8 <sect1 id="ch-config-locale" revision="systemd"> 9 9 <?dbhtml filename="locale.html"?> 10 10 … … 12 12 13 13 <indexterm zone="ch-config-locale"> 14 <primary sortas="e- /etc/profile">/etc/profile</primary>14 <primary sortas="e-etc-locale-conf">/etc/locale.conf</primary> 15 15 </indexterm> 16 16 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> 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> 23 20 24 21 <itemizedlist> … … 43 40 44 41 <para>Replace <replaceable><ll></replaceable> below with the two-letter code 45 for your desired language (e.g., < literal>en</literal>) and42 for your desired language (e.g., <quote>en</quote>) and 46 43 <replaceable><CC></replaceable> with the two-letter code for the appropriate 47 country (e.g., < literal>GB</literal>). <replaceable><charmap></replaceable> should44 country (e.g., <quote>GB</quote>). <replaceable><charmap></replaceable> should 48 45 be replaced with the canonical charmap for your chosen locale. Optional 49 modifiers such as < literal>@euro</literal> may also be present.</para>46 modifiers such as <quote>@euro</quote> may also be present.</para> 50 47 51 48 <para>The list of all locales supported by Glibc can be obtained by running … … 54 51 <screen role="nodump"><userinput>locale -a</userinput></screen> 55 52 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>. 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>. 59 55 Some applications cannot handle the various synonyms correctly (e.g., require 60 that < literal>UTF-8</literal> is written as <literal>UTF-8</literal>, not61 < literal>utf8</literal>), so it is the safest in most56 that <quote>UTF-8</quote> is written as <quote>UTF-8</quote>, not 57 <quote>utf8</quote>), so it is the safest in most 62 58 cases to choose the canonical name for a particular locale. To determine 63 59 the canonical name, run the following command, where <replaceable><locale 64 60 name></replaceable> is the output given by <command>locale -a</command> for 65 your preferred locale (<literal>en_GB.iso88591</literal> in our 66 example).</para> 61 your preferred locale (<quote>en_GB.iso88591</quote> in our example).</para> 67 62 68 63 <screen role="nodump"><userinput>LC_ALL=<replaceable><locale name></replaceable> locale charmap</userinput></screen> 69 64 70 <para>For the < literal>en_GB.iso88591</literal> locale, the above command65 <para>For the <quote>en_GB.iso88591</quote> locale, the above command 71 66 will print:</para> 72 67 73 68 <screen><computeroutput>ISO-8859-1</computeroutput></screen> 74 69 75 <para>This results in a final locale setting of < literal>en_GB.ISO-8859-1</literal>.70 <para>This results in a final locale setting of <quote>en_GB.ISO-8859-1</quote>. 76 71 It is important that the locale found using the heuristic above is tested prior 77 72 to it being added to the Bash startup files:</para> … … 96 91 Glibc.</para> 97 92 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. 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 98 109 <para>Other packages can also function incorrectly (but may not necessarily 99 110 display any error messages) if the locale name does not meet their expectations. … … 101 112 might provide some useful information.</para> 102 113 103 <para revision='systemd'>Once the proper locale settings have been104 determined, create the<filename>/etc/locale.conf</filename> file:</para>114 <para>Once the proper locale settings have been determined, create the 115 <filename>/etc/locale.conf</filename> file:</para> 105 116 106 <screen revision='systemd'><userinput>cat > /etc/locale.conf << "EOF"117 <screen><userinput>cat > /etc/locale.conf << "EOF" 107 118 <literal>LANG=<replaceable><ll>_<CC>.<charmap><@modifiers></replaceable></literal> 108 119 EOF</userinput></screen> 109 120 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 121 <para>Note that you can modify <filename>/etc/locale.conf</filename> with the 178 122 systemd <command>localectl</command> utility. To use 179 123 <command>localectl</command> for the example above, run:</para> 180 124 181 <screen r evision='systemd' role="nodump"><userinput>localectl set-locale LANG="<replaceable><ll>_<CC>.<charmap><@modifiers></replaceable>"</userinput></screen>125 <screen role="nodump"><userinput>localectl set-locale LANG="<replaceable><ll>_<CC>.<charmap><@modifiers></replaceable>"</userinput></screen> 182 126 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 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 188 131 en_US.UTF-8 but <envar>LC_CTYPE</envar> is set as just en_US is:</para> 189 132 190 <screen r evision='systemd' role="nodump"><userinput>localectl set-locale LANG="en_US.UTF-8" LC_CTYPE="en_US"</userinput></screen>133 <screen role="nodump"><userinput>localectl set-locale LANG="en_US.UTF-8" LC_CTYPE="en_US"</userinput></screen> 191 134 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> 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> 196 138 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> 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> 200 141 uses the US-ASCII 7-bit character set, and treats bytes with the high bit set 201 142 as invalid characters. That's why, e.g., the <command>ls</command> command 202 143 substitutes them with question marks in that locale. Also, an attempt to send 203 144 mail with such characters from Mutt or Pine results in non-RFC-conforming 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 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 207 147 if you are certain that you will never need 8-bit characters.</para> 208 148 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, see 152 <ulink url="&blfs-book;introduction/locale-issues.html"/>.</para> 153 --> 154 209 155 </sect1>
Note:
See TracChangeset
for help on using the changeset viewer.