/[gentoo]/xml/htdocs/doc/en/guide-localization.xml
Gentoo

Contents of /xml/htdocs/doc/en/guide-localization.xml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.50 - (show annotations) (download) (as text)
Sun Nov 30 11:28:59 2008 UTC (6 years ago) by jkt
Branch: MAIN
Changes since 1.49: +4 -5 lines
File MIME type: application/xml
#249273: Remove a bit misleading sentence about variable priority

Reported and clarified by r0bertz on IRC. The order in the table no longer
matches the priority (as we don't want users to mess with LC_ALL).

1 <?xml version='1.0' encoding='UTF-8'?>
2 <!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/guide-localization.xml,v 1.49 2008/10/10 16:03:49 jkt Exp $ -->
3 <!DOCTYPE guide SYSTEM "/dtd/guide.dtd">
4
5 <guide link="/doc/en/guide-localization.xml">
6 <title>Gentoo Linux Localization Guide</title>
7 <author title="Author">
8 Alexander Holler
9 </author>
10 <author title="Translator/Editor">
11 <mail link="slucy@uchicago.edu">Steven Lucy</mail>
12 </author>
13 <author title="Editor">
14 <mail link="bennyc@gentoo.org">Benny Chuang</mail>
15 </author>
16 <author title="Editor">
17 <mail link="pylon@gentoo.org">Lars Weiler</mail>
18 </author>
19 <author title="Editor">
20 <mail link="dertobi123@gentoo.org">Tobias Scherbaum</mail>
21 </author>
22 <author title="Editor">
23 <mail link="flammie@gentoo.org">Flammie Pirinen</mail>
24 </author>
25
26 <abstract>
27 This guide should help users localize their Gentoo Linux distribution to any
28 European locale. It uses Germany as a case-study, since it is translated from
29 the German doc. Includes configuration for use of the euro currency symbol.
30 </abstract>
31
32 <version>1.38</version>
33 <date>2008-11-30</date>
34
35 <chapter>
36 <title>Time zone</title>
37 <section>
38 <body>
39
40 <p>
41 In order to keep time properly, you need to select your timezone so that your
42 system knows where it is located. Look for your timezone in
43 <path>/usr/share/zoneinfo</path>. You then set your timezone in
44 <path>/etc/conf.d/clock</path>. Please avoid the
45 <path>/usr/share/zoneinfo/Etc/GMT*</path> timezones as their names do not
46 indicate the expected zones. For instance, <path>GMT-8</path> is in fact GMT+8.
47 </p>
48
49 <pre caption="Setting the timezone information">
50 # <i>ls /usr/share/zoneinfo</i>
51 <comment>(Suppose you want to use Brussels)</comment>
52 # <i>nano -w /etc/conf.d/clock</i>
53 TIMEZONE="Europe/Brussels"
54
55 # <i>date</i>
56 Wed Mar 8 00:46:05 CET 2006
57 </pre>
58
59 <note>
60 Make sure that the timezone indicator (in this case "CET")
61 is correct for your area.
62 </note>
63
64 <note>
65 You can set the value of <c>TZ</c> to be everything after the
66 <path>/usr/share/zoneinfo</path> in your shell rc file
67 (<path>.bash_profile</path> for bash) for a user-level setting. In this case
68 <c>TZ="Europe/Berlin"</c>.
69 </note>
70
71 </body>
72 </section>
73 </chapter>
74
75 <chapter>
76 <title>Hardware Clock</title>
77 <section>
78 <body>
79
80 <p>
81 In most Gentoo Linux installations, your hardware clock is set to
82 UTC (or GMT, Greenwich Mean Time) and then your timezone is
83 taken into account to determine the actual, local time. If,
84 for some reason, you need your hardware clock not to be in UTC,
85 you will need to edit <path>/etc/conf.d/clock</path> and change the
86 value of <c>CLOCK</c> from <c>UTC</c> to <c>local</c>.
87 </p>
88
89 <pre caption="local vs. GMT clock">
90 <comment>(recommended:)</comment>
91 CLOCK="UTC"
92 <comment>(or:)</comment>
93 CLOCK="local"
94 </pre>
95
96 </body>
97 </section>
98 </chapter>
99
100 <chapter>
101 <title>Locale system</title>
102 <section>
103 <title>What are locales?</title>
104 <body>
105
106 <p>
107 A Locale is a set of information that most programs use for determining country
108 and language specific settings. The locales and their data are part of the
109 system library and can be found at <path>/usr/share/locale</path> on most
110 systems. A locale name is generally named <c>ab_CD</c> where <c>ab</c> is your
111 two (or three) letter language code (as specified in ISO-639) and <c>CD</c> is
112 your two letter country code (as specified in ISO-3166). Variants are often
113 appended to locale names, e.g. <c>en_GB.utf8</c> or <c>de_DE@euro</c>. Please
114 explore <uri link="http://en.wikipedia.org/wiki/Locale">Wikipedia</uri> to read
115 more about locales and related articles.
116 </p>
117
118 </body>
119 </section>
120 <section id="variables">
121 <title>Environment variables for locales</title>
122 <body>
123
124 <p>
125 Locale settings are stored in environment variables. These are typically
126 set in the <path>/etc/env.d/02locale</path> (for system-wide
127 settings) and <path>~/.bashrc</path> (for user-specific settings) file.
128 The variables controlling different aspects of locale settings
129 are given in the table below. All of them
130 take one name of a locale in <c>ab_CD</c> format given above.
131 </p>
132
133 <table>
134 <tr>
135 <th>Variable name</th>
136 <th>Explanation</th>
137 </tr>
138 <tr>
139 <ti>LANG</ti>
140 <ti>
141 Defines all locale settings at once, while allowing further individual
142 customization via the LC_* settings below.
143 </ti>
144 </tr>
145 <tr>
146 <ti>LC_COLLATE</ti>
147 <ti>
148 Define alphabetical ordering of strings. This affects e.g. output of sorted
149 directory listing.
150 </ti>
151 </tr>
152 <tr>
153 <ti>LC_CTYPE</ti>
154 <ti>
155 Define the character handling properties for the system. This determines
156 which characters are seen as part of alphabet, numeric and so on. This also
157 determines the character set used, if applicable.
158 </ti>
159 </tr>
160 <tr>
161 <ti>LC_MESSAGES</ti>
162 <ti>
163 Programs' localizations for applications that use message based localization
164 scheme (majority of Gnu programs, see next chapters for closer information
165 which do, and how to get the programs, that don't, to work).
166 </ti>
167 </tr>
168 <tr>
169 <ti>LC_MONETARY</ti>
170 <ti>Defines currency units and formatting of currency type numeric values.</ti>
171 </tr>
172 <tr>
173 <ti>LC_NUMERIC</ti>
174 <ti>
175 Defines formatting of numeric values which aren't monetary. Affects things
176 such as thousand separator and decimal separator.
177 </ti>
178 </tr>
179 <tr>
180 <ti>LC_TIME</ti>
181 <ti>Defines formatting of dates and times.</ti>
182 </tr>
183 <tr>
184 <ti>LC_PAPER</ti>
185 <ti>Defines default paper size.</ti>
186 </tr>
187 <tr>
188 <ti>LC_ALL</ti>
189 <ti>
190 A special variable for overriding all other settings.
191 </ti>
192 </tr>
193 </table>
194
195 <note>
196 Some programs are written in such a way that they expect traditional English
197 ordering of the alphabet, while some locales, most notably the Estonian one, use
198 a different ordering. Therefore it's recommended to explicitly set LC_COLLATE to C
199 when dealing with system-wide settings.
200 </note>
201
202 <warn>
203 For the same reason, using LC_ALL is strongly discouraged. Please use it only
204 when testing and never set it in a startup file.
205 </warn>
206
207 <p>
208 Most typically users only set the LANG variable on the global basis:
209 </p>
210
211 <pre caption="Setting the default system locale in /etc/env.d/02locale">
212 LANG="de_DE.utf8@euro"
213 LC_COLLATE="C"
214 </pre>
215
216 <note>
217 Append <c>@euro</c> to your locale if you want to use the Euro
218 currency symbol (€)
219 </note>
220
221 <p>
222 It's also possible, and pretty common especially in a more traditional UNIX
223 environment, to leave the global settings unchanged, i.e. in the "<c>C</c>"
224 locale. Users can still specify their preferred locale in their own shell RC
225 file:
226 </p>
227
228 <pre caption="Setting the user locale in ~/.bashrc">
229 export LANG="de_DE.utf8@euro"
230 export LC_COLLATE="C"
231 </pre>
232
233 <p>
234 Another way of configuring system is to leave it in the default C locale, but
235 enable UTF-8 character representation at the same time. This option is achieved
236 using the following settings in <path>/etc/env.d/02locale</path>:
237 </p>
238
239 <pre caption="Using traditional C locale while specifying UTF-8">
240 LC_CTYPE=de_DE.utf8
241 </pre>
242
243 <p>
244 Using the above snippet, users will be able to see localized file names
245 properly, while not being forced to your preferred language.
246 </p>
247
248 <p>
249 For message based localization to work in programs that support it, you will
250 probably need to have programs compiled with the <c>nls</c> (Native language
251 support) USE flag set. Most of the programs using nls also need the gettext
252 library to extract and use localized messages. Of course, Portage will
253 automatically install it when needed.
254 </p>
255
256 <p>
257 Once you have set the right locale, be sure to update your environment
258 variables to make your system aware of the change:
259 </p>
260
261 <pre caption="Update the environment">
262 <comment>(For system-wide default locale:)</comment>
263 # <i>env-update &amp;&amp; source /etc/profile</i>
264
265 <comment>(For user-specific locale:)</comment>
266 $ <i>source ~/.bashrc</i>
267 </pre>
268
269 <p>
270 After this, you will need to kill your X server by pressing
271 <c>Ctrl-Alt-Backspace</c>, log out, then log in as user.
272 </p>
273
274 <p>
275 Now, verify that the changes have taken effect:
276 </p>
277
278 <pre caption="Verify env changes">
279 $ <i>locale</i>
280 </pre>
281
282 <p>
283 There is also additional localisation variable called LINGUAS, which affects
284 to localisation files that get installed in gettext-based programs, and decides
285 used localisation for some specific software packages, such as
286 <c>kde-base/kde-i18n</c> and <c>app-office/openoffice</c>. The variable
287 takes in <e>space</e>-separated list of language codes, and suggested
288 place to set it is <path>/etc/make.conf</path>:
289 </p>
290
291 <pre caption="Setting LINGUAS in make.conf">
292 # <i>nano -w /etc/make.conf</i>
293 <comment>(Add in the LINGUAS variable. For instance,
294 for German, Finnish and English:)</comment>
295 LINGUAS="de fi en"
296 </pre>
297
298
299 </body>
300 </section>
301 <section>
302 <title>Generating Specific Locales</title>
303 <body>
304
305 <p>
306 If you use a locale that isn't available by default, you should use
307 <c>localedef</c> to generate your locale. For instance:
308 </p>
309
310 <pre caption="Generating a locale using localedef">
311 # <i>localedef -c -i en_US -f ISO-8859-15 en_US.ISO-8859-15</i>
312 </pre>
313
314 <p>
315 After having generated the locale, you can export the LANG variable as you see
316 fit.
317 </p>
318
319 <pre caption="Exporting the LANG variable">
320 # <i>export LANG="en_US.ISO-8859-15"</i>
321 </pre>
322
323 <p>
324 Be sure to update the environment after the change:
325 </p>
326
327 <pre caption="Update the environment">
328 # <i>env-update &amp;&amp; source /etc/profile</i>
329 </pre>
330
331 <p>
332 After this, you will need to kill your X server by pressing
333 <c>Ctrl-Alt-Backspace</c>, log out, then log in as user.
334 </p>
335
336 </body>
337 </section>
338 <section>
339 <title>Generating locales for glibc</title>
340 <body>
341
342 <p>
343 You will probably only use one or maybe two locales on your system. You can
344 specify locales you will need in <path>/etc/locale.gen</path>.
345 </p>
346
347 <pre caption="Adding locales to /etc/locale.gen">
348 en_GB ISO-8859-1
349 en_GB.UTF-8 UTF-8
350 de_DE ISO-8859-1
351 de_DE@euro ISO-8859-15
352 </pre>
353
354 <p>
355 The next step is to run <c>locale-gen</c>. It will generate all the locales you
356 have specified in the <path>/etc/locale.gen</path> file.
357 </p>
358
359 <note>
360 <c>locale-gen</c> is available in <c>glibc-2.3.6-r4</c> and newer. If you have
361 an older version of glibc, you should update it now.
362 </note>
363
364 <p>
365 You can verify that your selected locales are available by running <c>locale
366 -a</c>.
367 </p>
368
369 </body>
370 </section>
371 </chapter>
372
373 <chapter>
374 <title>Keyboard layout for the console</title>
375 <section>
376 <body>
377
378 <p>
379 The keyboard layout used by the console is set in
380 <path>/etc/conf.d/keymaps</path> by the <c>KEYMAP</c> variable.
381 Valid values can be found in
382 <path>/usr/share/keymaps/<c>{arch}</c>/</path>.
383 <path>i386</path> has further subdivisions into layout
384 (<path>qwerty/</path>, <path>azerty/</path>, etc.). Some
385 languages have multiple options, so you may wish to experiment
386 to decide which one fits your needs best.
387 </p>
388
389 <pre caption="Setting the console keymap">
390 KEYMAP="de"
391 KEYMAP="de-latin1"
392 KEYMAP="de-latin1-nodeadkeys"
393 </pre>
394
395 </body>
396 </section>
397 </chapter>
398
399 <chapter>
400 <title>Keyboard layout for the X server</title>
401 <section>
402 <body>
403
404 <p>
405 The keyboard layout to be used by the X server is specified
406 in <path>/etc/X11/xorg.conf</path> by the <c>XkbLayout</c>
407 option.
408 </p>
409
410 <pre caption="Setting the X keymap">
411 Section "InputDevice"
412 Identifier "Keyboard1"
413 ...
414 Option "XkbLayout" "de"
415 #Option "XkbModel" "pc105" <comment>## this is for international keyboards.</comment>
416 # Option "XkbVariant" "nodeadkeys" <comment>## this would be used for xterm input</comment>
417 ...
418 </pre>
419
420 <p>
421 If you have an international keyboard layout, you should set the option
422 <c>XkbModel</c> to <c>pc102</c> or <c>pc105</c>, as this will allow mapping of the
423 additional keys specific to your keyboard.
424 </p>
425
426 <p>
427 Deadkeys allow you to press keys that will not show immediately but will be
428 combined with another letter to produce a single character such as é,è,á,à,
429 etc. Setting <c>XkbVariant</c> to <c>nodeadkeys</c> allows input these special
430 characters into X terminals.
431 </p>
432
433 <p>
434 If you would like to switch between more than one keyboard layout (for example
435 English and Russian), all you have to do is add a few lines to
436 <path>xorg.conf</path> that specify the desired layouts and the shortcut
437 command.
438 </p>
439
440 <pre caption="Switching between two keyboard layouts">
441 Section "InputDevice"
442 Identifier "Keyboard1"
443 ...
444 Option "XkbLayout" "us,ru"
445 Option "XkbOptions" "grp:alt_shift_toggle,grp_led:scroll"
446 </pre>
447
448 <p>
449 Here, <c>XkbOptions</c> allows you to toggle between keyboard layouts by simply
450 pressing <c>Alt-Shift</c>. This will also toggle the Scroll Lock light on or
451 off, thanks to the <c>grp_led:scroll</c> option. This is a handy visual
452 indicator of which keyboard layout you are using at the moment.
453 </p>
454
455 </body>
456 </section>
457 </chapter>
458
459 <chapter>
460 <title>KDE</title>
461 <section>
462 <body>
463
464 <p>
465 For KDE you have to install the <c>kde-base/kde-i18n</c> package. Kde-i18n
466 respects <uri link="#variables">LINGUAS variable</uri> described earlier.
467 </p>
468
469 </body>
470 </section>
471 </chapter>
472
473 <chapter>
474 <title>The Euro Symbol for the Console</title>
475 <section>
476 <body>
477
478 <p>
479 In order to get your console to display the Euro symbol, you
480 will need to set <c>CONSOLEFONT</c> in
481 <path>/etc/conf.d/consolefont</path> to a file found in
482 <path>/usr/share/consolefonts/</path> (without the
483 <c>.psfu.gz</c>). <c>lat9w-16</c> has the Euro symbol.
484 </p>
485
486 <pre caption="Setting the console font">
487 CONSOLEFONT="lat9w-16"
488 </pre>
489
490 <p>
491 You should verify that <c>CONSOLEFONT</c> is in the boot runlevel:
492 </p>
493
494 <pre caption="Verify the proper runlevel">
495 # <i>rc-update -v show | grep -i consolefont</i>
496 </pre>
497
498 <p>
499 If no runlevel is displayed for <c>CONSOLEFONT</c>, then add it to the proper level:
500 </p>
501
502 <pre caption="Add consolefont to boot">
503 # <i>rc-update add consolefont boot</i>
504 </pre>
505
506 </body>
507 </section>
508 </chapter>
509
510 <chapter>
511 <title>The Euro Symbol in X</title>
512 <section>
513 <title>Most Applications</title>
514 <body>
515
516 <p>
517 Getting the Euro symbol to work properly in X is a little bit tougher. The
518 first thing you should do is change the <c>fixed</c> and <c>variable</c>
519 definitions in <path>/usr/share/fonts/misc/fonts.alias</path> to end in
520 <c>iso8859-15</c> instead of <c>iso8859-1</c>.
521 </p>
522
523 <pre caption="Setting default X fonts">
524 fixed -misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-iso8859-15
525 variable -*-helvetica-bold-r-normal-*-*-120-*-*-*-*-iso8859-15
526 </pre>
527
528 <p>
529 Some applications use their own font, and you will have to tell them separately
530 to use a font with the Euro symbol. You can do this at a user-specific level in
531 <path>.Xdefaults</path> (you can copy this file to <path>/etc/skel/</path> for
532 use by new users), or at a global level for any application with a resource file
533 in <path>/usr/share/X11/app-defaults/</path> (like xterm). In these files you
534 generally have to change an existing line, rather than adding a new one. To
535 change our xterm font, for instance:
536 </p>
537
538 <pre caption="Setting fonts for xterm">
539 <comment>(in your home directory)</comment>
540 $ <i>echo 'XTerm*font: fixed' >> .Xresources </i>
541 $ <i>xrdb -merge .Xresources</i>
542 </pre>
543
544 </body>
545 </section>
546 <section>
547 <title>The Euro symbol in (X)Emacs</title>
548 <body>
549
550 <p>
551 To use the Euro symbol in (X)Emacs, add the following to
552 <path>.Xdefaults</path>:
553 </p>
554
555 <pre caption="setting the font for emacs">
556 Emacs.default.attributeFont: -*-courier-medium-r-*-*-*-120-*-*-*-*-iso8859-15
557 </pre>
558
559 <p>
560 For XEmacs (not plain Emacs), you have to do a little
561 more. In <path>/home/user/.xemacs/init.el</path>, add:
562 </p>
563
564 <pre caption="setting the font for xemacs">
565 (define-key global-map '(EuroSign) '[€])
566 </pre>
567
568 <note>
569 The symbol in the []s is the Euro symbol.
570 </note>
571
572 </body>
573 </section>
574 <section>
575 <title>OpenOffice.Org</title>
576 <body>
577
578 <p>
579 The current stable <c>app-office/openoffice</c> and
580 <c>app-office/openoffice-bin</c> ebuilds support the <uri
581 link="#variables">LINGUAS variable</uri> for selecting installed GUI language
582 packs. To see the status of GUI translation, hyphenation, spell checking and
583 other localisations on your language, please refer to <uri
584 link="http://l10n.openoffice.org/languages.html">OpenOffice.Org localisation
585 web site</uri>.
586 </p>
587
588 </body>
589 </section>
590 </chapter>
591
592 </guide>

  ViewVC Help
Powered by ViewVC 1.1.20