/[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.39 - (show annotations) (download) (as text)
Thu May 25 16:22:37 2006 UTC (8 years, 2 months ago) by neysx
Branch: MAIN
Changes since 1.38: +34 -14 lines
File MIME type: application/xml
#134032 Mention system locale vs user locale

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

  ViewVC Help
Powered by ViewVC 1.1.20