/[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 - (hide annotations) (download) (as text)
Sun Nov 30 11:28:59 2008 UTC (5 years, 9 months 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 swift 1.6 <?xml version='1.0' encoding='UTF-8'?>
2 jkt 1.50 <!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/guide-localization.xml,v 1.49 2008/10/10 16:03:49 jkt Exp $ -->
3 swift 1.6 <!DOCTYPE guide SYSTEM "/dtd/guide.dtd">
4    
5     <guide link="/doc/en/guide-localization.xml">
6 antifa 1.4 <title>Gentoo Linux Localization Guide</title>
7 dertobi123 1.12 <author title="Author">
8 pylon 1.16 Alexander Holler
9 drobbins 1.1 </author>
10 dertobi123 1.12 <author title="Translator/Editor">
11     <mail link="slucy@uchicago.edu">Steven Lucy</mail>
12 antifa 1.4 </author>
13 bennyc 1.8 <author title="Editor">
14     <mail link="bennyc@gentoo.org">Benny Chuang</mail>
15     </author>
16 dertobi123 1.11 <author title="Editor">
17     <mail link="pylon@gentoo.org">Lars Weiler</mail>
18     </author>
19 dertobi123 1.15 <author title="Editor">
20     <mail link="dertobi123@gentoo.org">Tobias Scherbaum</mail>
21     </author>
22 swift 1.18 <author title="Editor">
23     <mail link="flammie@gentoo.org">Flammie Pirinen</mail>
24     </author>
25 dertobi123 1.12
26 antifa 1.4 <abstract>
27     This guide should help users localize their Gentoo Linux distribution to any
28 dertobi123 1.12 European locale. It uses Germany as a case-study, since it is translated from
29 swift 1.23 the German doc. Includes configuration for use of the euro currency symbol.
30 antifa 1.4 </abstract>
31 drobbins 1.1
32 jkt 1.50 <version>1.38</version>
33     <date>2008-11-30</date>
34 dertobi123 1.12
35 drobbins 1.1 <chapter>
36 swift 1.23 <title>Time zone</title>
37 drobbins 1.1 <section>
38 dertobi123 1.12 <body>
39    
40     <p>
41 nightmorph 1.46 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 neysx 1.31 <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 dertobi123 1.12 </p>
48    
49 nightmorph 1.46 <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 antifa 1.4 # <i>date</i>
56 nightmorph 1.46 Wed Mar 8 00:46:05 CET 2006
57 drobbins 1.1 </pre>
58 dertobi123 1.12
59     <note>
60 flammie 1.41 Make sure that the timezone indicator (in this case "CET")
61 dertobi123 1.12 is correct for your area.
62     </note>
63    
64     <note>
65 cam 1.13 You can set the value of <c>TZ</c> to be everything after the
66 aaby 1.10 <path>/usr/share/zoneinfo</path> in your shell rc file
67 antifa 1.4 (<path>.bash_profile</path> for bash) for a user-level setting. In this case
68 cam 1.13 <c>TZ="Europe/Berlin"</c>.
69 dertobi123 1.12 </note>
70    
71     </body>
72 drobbins 1.1 </section>
73     </chapter>
74    
75     <chapter>
76 swift 1.26 <title>Hardware Clock</title>
77 drobbins 1.1 <section>
78 dertobi123 1.12 <body>
79    
80     <p>
81 swift 1.26 In most Gentoo Linux installations, your hardware clock is set to
82 swift 1.23 UTC (or GMT, Greenwich Mean Time) and then your timezone is
83 dertobi123 1.12 taken into account to determine the actual, local time. If,
84 swift 1.26 for some reason, you need your hardware clock not to be in UTC,
85 fox2mike 1.28 you will need to edit <path>/etc/conf.d/clock</path> and change the
86 swift 1.26 value of <c>CLOCK</c> from <c>UTC</c> to <c>local</c>.
87 dertobi123 1.12 </p>
88 antifa 1.4
89     <pre caption="local vs. GMT clock">
90 neysx 1.20 <comment>(recommended:)</comment>
91 dertobi123 1.12 CLOCK="UTC"
92 neysx 1.20 <comment>(or:)</comment>
93 dertobi123 1.12 CLOCK="local"
94 drobbins 1.1 </pre>
95 dertobi123 1.12
96     </body>
97 drobbins 1.1 </section>
98     </chapter>
99    
100     <chapter>
101 swift 1.18 <title>Locale system</title>
102 drobbins 1.1 <section>
103 swift 1.18 <title>What are locales?</title>
104 dertobi123 1.12 <body>
105    
106     <p>
107 neysx 1.48 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 swift 1.18 </p>
117    
118     </body>
119     </section>
120 flammie 1.32 <section id="variables">
121 swift 1.18 <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 jkt 1.50 are given in the table below. All of them
130 swift 1.18 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 jkt 1.49 <ti>LANG</ti>
140 swift 1.18 <ti>
141 jkt 1.49 Defines all locale settings at once, while allowing further individual
142     customization via the LC_* settings below.
143 swift 1.18 </ti>
144     </tr>
145     <tr>
146     <ti>LC_COLLATE</ti>
147     <ti>
148 flammie 1.42 Define alphabetical ordering of strings. This affects e.g. output of sorted
149 swift 1.23 directory listing.
150 swift 1.18 </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 jkt 1.49 <ti>LC_ALL</ti>
189 swift 1.18 <ti>
190 jkt 1.49 A special variable for overriding all other settings.
191 swift 1.18 </ti>
192     </tr>
193     </table>
194    
195 swift 1.25 <note>
196 jkt 1.49 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 swift 1.25 </note>
201    
202 jkt 1.49 <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 swift 1.18 <p>
208 jkt 1.49 Most typically users only set the LANG variable on the global basis:
209 dertobi123 1.12 </p>
210    
211 jkt 1.49 <pre caption="Setting the default system locale in /etc/env.d/02locale">
212     LANG="de_DE.utf8@euro"
213     LC_COLLATE="C"
214 drobbins 1.1 </pre>
215 dertobi123 1.12
216     <note>
217 swift 1.18 Append <c>@euro</c> to your locale if you want to use the Euro
218 neysx 1.39 currency symbol (€)
219 dertobi123 1.12 </note>
220    
221 swift 1.18 <p>
222 jkt 1.49 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 neysx 1.39 </p>
227    
228 jkt 1.49 <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 neysx 1.39 </pre>
242    
243     <p>
244 jkt 1.49 Using the above snippet, users will be able to see localized file names
245     properly, while not being forced to your preferred language.
246 neysx 1.39 </p>
247    
248     <p>
249 swift 1.18 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 neysx 1.39 library to extract and use localized messages. Of course, Portage will
253 swift 1.18 automatically install it when needed.
254     </p>
255    
256 flammie 1.32 <p>
257 rane 1.35 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 neysx 1.39 <comment>(For system-wide default locale:)</comment>
263 rane 1.35 # <i>env-update &amp;&amp; source /etc/profile</i>
264 neysx 1.39
265 jkt 1.40 <comment>(For user-specific locale:)</comment>
266 neysx 1.39 $ <i>source ~/.bashrc</i>
267 rane 1.35 </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 jkt 1.49 $ <i>locale</i>
280 rane 1.35 </pre>
281    
282     <p>
283 flammie 1.32 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 neysx 1.39 <pre caption="Setting LINGUAS in make.conf">
292 flammie 1.32 # <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 dertobi123 1.12 </body>
300 drobbins 1.1 </section>
301 swift 1.14 <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 rane 1.35 <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 swift 1.14 </body>
337     </section>
338 dertobi123 1.15 <section>
339 rane 1.43 <title>Generating locales for glibc</title>
340 dertobi123 1.15 <body>
341    
342     <p>
343 rane 1.43 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 dertobi123 1.15 </p>
346    
347 rane 1.43 <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 dertobi123 1.15 </pre>
353    
354     <p>
355 rane 1.43 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 dertobi123 1.15 </p>
358    
359 rane 1.43 <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 dertobi123 1.15
364 nightmorph 1.44 <p>
365     You can verify that your selected locales are available by running <c>locale
366     -a</c>.
367     </p>
368    
369 dertobi123 1.15 </body>
370     </section>
371 drobbins 1.1 </chapter>
372    
373     <chapter>
374 antifa 1.4 <title>Keyboard layout for the console</title>
375 drobbins 1.1 <section>
376 dertobi123 1.12 <body>
377    
378     <p>
379     The keyboard layout used by the console is set in
380 fox2mike 1.27 <path>/etc/conf.d/keymaps</path> by the <c>KEYMAP</c> variable.
381 dertobi123 1.12 Valid values can be found in
382 cam 1.13 <path>/usr/share/keymaps/<c>{arch}</c>/</path>.
383 dertobi123 1.12 <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 neysx 1.39 <pre caption="Setting the console keymap">
390 dertobi123 1.12 KEYMAP="de"
391     KEYMAP="de-latin1"
392     KEYMAP="de-latin1-nodeadkeys"
393 drobbins 1.1 </pre>
394 dertobi123 1.12
395     </body>
396 drobbins 1.1 </section>
397     </chapter>
398    
399     <chapter>
400 antifa 1.4 <title>Keyboard layout for the X server</title>
401 drobbins 1.1 <section>
402 dertobi123 1.12 <body>
403    
404     <p>
405     The keyboard layout to be used by the X server is specified
406 alin 1.21 in <path>/etc/X11/xorg.conf</path> by the <c>XkbLayout</c>
407 dertobi123 1.12 option.
408     </p>
409    
410 neysx 1.39 <pre caption="Setting the X keymap">
411 drobbins 1.1 Section "InputDevice"
412     Identifier "Keyboard1"
413     ...
414     Option "XkbLayout" "de"
415 rane 1.35 #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 drobbins 1.1 ...
444 rane 1.35 Option "XkbLayout" "us,ru"
445     Option "XkbOptions" "grp:alt_shift_toggle,grp_led:scroll"
446 drobbins 1.1 </pre>
447 dertobi123 1.12
448 rane 1.35 <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 dertobi123 1.12 </body>
456 drobbins 1.1 </section>
457     </chapter>
458    
459     <chapter>
460 dertobi123 1.11 <title>KDE</title>
461     <section>
462     <body>
463    
464     <p>
465 flammie 1.32 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 swift 1.22 </p>
468 dertobi123 1.11
469     </body>
470     </section>
471     </chapter>
472    
473     <chapter>
474 antifa 1.4 <title>The Euro Symbol for the Console</title>
475 drobbins 1.1 <section>
476 dertobi123 1.12 <body>
477    
478     <p>
479     In order to get your console to display the Euro symbol, you
480 cam 1.13 will need to set <c>CONSOLEFONT</c> in
481 rane 1.35 <path>/etc/conf.d/consolefont</path> to a file found in
482 dertobi123 1.12 <path>/usr/share/consolefonts/</path> (without the
483     <c>.psfu.gz</c>). <c>lat9w-16</c> has the Euro symbol.
484     </p>
485    
486 neysx 1.39 <pre caption="Setting the console font">
487 dertobi123 1.12 CONSOLEFONT="lat9w-16"
488 drobbins 1.1 </pre>
489 dertobi123 1.12
490 rane 1.35 <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 nightmorph 1.47 # <i>rc-update -v show | grep -i consolefont</i>
496 rane 1.35 </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 dertobi123 1.12 </body>
507 drobbins 1.1 </section>
508     </chapter>
509    
510     <chapter>
511 dertobi123 1.12 <title>The Euro Symbol in X</title>
512 drobbins 1.1 <section>
513 dertobi123 1.12 <title>Most Applications</title>
514     <body>
515    
516     <p>
517 nightmorph 1.45 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 dertobi123 1.12 </p>
522    
523 neysx 1.39 <pre caption="Setting default X fonts">
524 dertobi123 1.12 fixed -misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-iso8859-15
525     variable -*-helvetica-bold-r-normal-*-*-120-*-*-*-*-iso8859-15
526 antifa 1.4 </pre>
527 dertobi123 1.12
528     <p>
529 nightmorph 1.45 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 dertobi123 1.12 </p>
537    
538 neysx 1.39 <pre caption="Setting fonts for xterm">
539 neysx 1.20 <comment>(in your home directory)</comment>
540 nightmorph 1.38 $ <i>echo 'XTerm*font: fixed' >> .Xresources </i>
541     $ <i>xrdb -merge .Xresources</i>
542 drobbins 1.1 </pre>
543 dertobi123 1.12
544     </body>
545 drobbins 1.1 </section>
546 dertobi123 1.12 <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 drobbins 1.1
555 antifa 1.4 <pre caption="setting the font for emacs">
556 dertobi123 1.12 Emacs.default.attributeFont: -*-courier-medium-r-*-*-*-120-*-*-*-*-iso8859-15
557 drobbins 1.1 </pre>
558 dertobi123 1.12
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 antifa 1.4 <pre caption="setting the font for xemacs">
565 neysx 1.39 (define-key global-map '(EuroSign) '[€])
566 drobbins 1.1 </pre>
567 dertobi123 1.12
568     <note>
569     The symbol in the []s is the Euro symbol.
570     </note>
571    
572     </body>
573     </section>
574     <section>
575 flammie 1.32 <title>OpenOffice.Org</title>
576 dertobi123 1.12 <body>
577    
578     <p>
579 nightmorph 1.36 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 dertobi123 1.12 </p>
587    
588     </body>
589 bennyc 1.8 </section>
590 drobbins 1.1 </chapter>
591    
592     </guide>

  ViewVC Help
Powered by ViewVC 1.1.20