/[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.49 - (show annotations) (download) (as text)
Fri Oct 10 16:03:49 2008 UTC (6 years ago) by jkt
Branch: MAIN
Changes since 1.48: +41 -25 lines
File MIME type: application/xml
#208082: don't use LC_ALL, prefer system-wide LANG, don't set LC_CTYPE when LANG
is already set, advertise utf-8 a bit more...

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

  ViewVC Help
Powered by ViewVC 1.1.20