1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
|
<?xml version="1.0" encoding="iso-8859-1"?>
<!--
The FreeBSD Documentation Project
$FreeBSD$
-->
<chapter id="l10n">
<chapterinfo>
<authorgroup>
<author>
<firstname>Andrey</firstname>
<surname>Chernov</surname>
<contrib>Contributed by </contrib>
</author>
</authorgroup>
<authorgroup>
<author>
<firstname>Michael C.</firstname>
<surname>Wu</surname>
<contrib>Rewritten by </contrib>
</author>
<!-- 30 Nv 2000 -->
</authorgroup>
</chapterinfo>
<title>Localization -
<acronym>i18n</acronym>/<acronym>L10n</acronym> Usage and
Setup</title>
<sect1 id="l10n-synopsis">
<title>Synopsis</title>
<para>&os; is a distributed project with users and contributors
located all over the world. This chapter discusses the
internationalization and localization features of &os; that
allow non-English speaking users to get real work done. Since
there are many aspects of the <acronym>i18n</acronym>
implementation in both the system and application levels, more
specific sources of documentation are referred to, where
applicable.</para>
<para>After reading this chapter, you will know:</para>
<itemizedlist>
<listitem>
<para>How different languages and locales are encoded on
modern operating systems.</para>
</listitem>
<listitem>
<para>How to set the locale for a login shell.</para>
</listitem>
<listitem>
<para>How to configure the console for non-English
languages.</para>
</listitem>
<listitem>
<para>How to use <application>Xorg</application>effectively
with different languages.</para>
</listitem>
<listitem>
<para>Where to find more information about writing
<acronym>i18n</acronym>-compliant applications.</para>
</listitem>
</itemizedlist>
<para>Before reading this chapter, you should:</para>
<itemizedlist>
<listitem><para>Know how to <link linkend="ports">install
additional third-party
applications</link>.</para></listitem>
</itemizedlist>
</sect1>
<sect1 id="l10n-basics">
<title>The Basics</title>
<sect2>
<title>What Is
<acronym>i18n</acronym>/<acronym>L10n</acronym>?</title>
<indexterm>
<primary>internationalization</primary>
<see>localization</see>
</indexterm>
<indexterm><primary>localization</primary></indexterm>
<para>The term internationalization has been shortened to
<acronym>i18n</acronym>, which represents the number of
letters between the first and the last letters of
internationalization. <acronym>L10n</acronym> uses the
same naming scheme, coming from <quote>localization</quote>.
Combined together,
<acronym>i18n</acronym>/<acronym>L10n</acronym> methods,
protocols, and applications allow users to use languages of
their choice.</para>
<para><acronym>i18n</acronym> applications are programmed using
<acronym>i18n</acronym> kits under libraries. These allow
developers to write a simple file and translate displayed
menus and texts to each language.</para>
</sect2>
<sect2>
<title>Why Use
<acronym>i18n</acronym>/<acronym>L10n</acronym>?</title>
<para>Using <acronym>i18n</acronym>/<acronym>L10n</acronym>
allows a user to view, input, or process data in non-English
languages.</para>
</sect2>
<sect2>
<title>Which Languages Are Supported?</title>
<para><acronym>i18n</acronym> and <acronym>L10n</acronym> are
not &os; specific. Currently, one can choose from most of the
major languages, including but not limited to: Chinese,
German, Japanese, Korean, French, Russian, and
Vietnamese.</para>
</sect2>
</sect1>
<sect1 id="using-localization">
<title>Using Localization</title>
<indexterm><primary>locale</primary></indexterm>
<para>Localization settings are based on three main terms:
Language Code, Country Code, and Encoding. Locale names are
constructed from these parts as follows:</para>
<programlisting><replaceable>LanguageCode</replaceable>_<replaceable>CountryCode</replaceable>.<replaceable>Encoding</replaceable></programlisting>
<sect2>
<title>Language and Country Codes</title>
<indexterm><primary>language codes</primary></indexterm>
<indexterm><primary>country codes</primary></indexterm>
<para>In order to localize a &os; system to a specific language,
the user needs to determine the codes for the specific country
and language as the country code tells applications which
variation of the given language to use. The following are
examples of language/country codes:</para>
<informaltable frame="none" pgwide="1">
<tgroup cols="2">
<thead>
<row>
<entry>Language/Country Code</entry>
<entry>Description</entry>
</row>
</thead>
<tbody>
<row>
<entry>en_US</entry>
<entry>English - United States</entry>
</row>
<row>
<entry>ru_RU</entry>
<entry>Russian for Russia</entry>
</row>
<row>
<entry>zh_TW</entry>
<entry>Traditional Chinese for Taiwan</entry>
</row>
</tbody>
</tgroup>
</informaltable>
<para>A complete listing of available locales can be found by
typing:</para>
<screen>&prompt.user; <userinput>locale -a</userinput></screen>
</sect2>
<sect2>
<title>Encodings</title>
<indexterm><primary>encodings</primary></indexterm>
<indexterm><primary>ASCII</primary></indexterm>
<para>Some languages use non-ASCII encodings that are 8-bit,
wide, or multibyte characters. For more information on these
encodings, refer to &man.multibyte.3;. Older applications do
not recognize these encodings and mistake them for control
characters. Newer applications usually recognize 8-bit
characters. Depending on the implementation, users may be
required to compile an application with wide or multibyte
character support, or configure it correctly. To provide
application support for wide or multibyte characters, the
<ulink url="&url.base;/ports/index.html">&os; Ports
Collection</ulink> contains programs for several languages.
Refer to the <acronym>i18n</acronym> documentation in the
respective &os; port.</para>
<para>Specifically, the user needs to look at the application
documentation to decide how to configure it correctly or to
determine which compile options to use when building the
port.</para>
<para>Some things to keep in mind are:</para>
<itemizedlist>
<listitem>
<para>Language specific single C chars character sets
such as ISO8859-1, ISO8859-15, KOI8-R, and CP437. These
are described in &man.multibyte.3;.</para>
</listitem>
<listitem>
<para>Wide or multibyte encodings such as EUC and
Big5.</para>
</listitem>
</itemizedlist>
<para>The active list of character sets can be found at the
<ulink
url="http://www.iana.org/assignments/character-sets">IANA
Registry</ulink>.</para>
<note>
<para>&os; uses Xorg-compatible locale encodings
instead.</para>
</note>
<para>In the &os; Ports Collection, <acronym>i18n</acronym>
applications include <literal>i18n</literal> in their names
for easy identification. However, they do not always support
the language needed.</para>
</sect2>
<sect2 id="setting-locale">
<title>Setting Locale</title>
<para>Usually it is sufficient to export the value of the
locale name as <envar>LANG</envar> in the login shell. This
could be done in the user's <filename>~/.login_conf</filename>
or in the startup file of the user's shell:
(<filename>~/.profile</filename>,
<filename>~/.bashrc</filename>, or
<filename>~/.cshrc</filename>). There is no need to set the
locale subsets such as <envar>LC_CTYPE</envar> or
<envar>LC_CTIME</envar>. Refer to language-specific &os;
documentation for more information.</para>
<para>Each user should set the following two environment
variables in their configuration files:</para>
<itemizedlist>
<indexterm><primary>POSIX</primary></indexterm>
<listitem>
<para><envar>LANG</envar> for &posix; &man.setlocale.3;
family functions</para>
</listitem>
<listitem>
<indexterm><primary>MIME</primary></indexterm>
<para><envar>MM_CHARSET</envar> for applications' MIME
character set</para>
</listitem>
</itemizedlist>
<para>These should be set in the user's shell configuration, the
specific application configuration, and the
<application>Xorg</application> configuration.</para>
<sect3>
<title>Setting Locale Methods</title>
<indexterm><primary>locale</primary></indexterm>
<indexterm><primary>login class</primary></indexterm>
<para>This section describes the two methods for setting
locale. The first is recommended and assigns the
environment variables in the <link
linkend="login-class">login class</link>. The second
method adds the environment variable assignments to the
system's shell <link linkend="startup-file">startup
file</link>.</para>
<sect4 id="login-class">
<title>Login Classes Method</title>
<para>This method allows environment variables needed for
locale name and MIME character sets to be assigned once
for every possible shell instead of adding specific shell
assignments to each shell's startup file. <link
linkend="usr-setup">User Level Setup</link> can be
performed by each user while <link
linkend="adm-setup">Administrator Level Setup</link>
requires superuser privileges.</para>
<sect5 id="usr-setup">
<title>User Level Setup</title>
<para>This provides a minimal example of a
<filename>.login_conf</filename> located in a user's
home directory which has both variables set for the
Latin-1 encoding:</para>
<programlisting>me:\
:charset=ISO-8859-1:\
:lang=de_DE.ISO8859-1:</programlisting>
<indexterm><primary>Traditional Chinese</primary>
<secondary>BIG-5 encoding</secondary></indexterm>
<para>Here is an example of a user's
<filename>.login_conf</filename> that sets the variables
for Traditional Chinese in BIG-5 encoding. More
variables are set because some applications do not
correctly respect locale variables for Chinese,
Japanese, and Korean.</para>
<programlisting>#Users who do not wish to use monetary units or time formats
#of Taiwan can manually change each variable
me:\
:lang=zh_TW.Big5:\
:setenv=LC_ALL=zh_TW.Big5:\
:setenv=LC_COLLATE=zh_TW.Big5:\
:setenv=LC_CTYPE=zh_TW.Big5:\
:setenv=LC_MESSAGES=zh_TW.Big5:\
:setenv=LC_MONETARY=zh_TW.Big5:\
:setenv=LC_NUMERIC=zh_TW.Big5:\
:setenv=LC_TIME=zh_TW.Big5:\
:charset=big5:\
:xmodifiers="@im=gcin": #Set gcin as the XIM Input Server</programlisting>
<para>See <link linkend="adm-setup">Administrator Level
Setup</link> and &man.login.conf.5; for more
details.</para>
</sect5>
<sect5 id="adm-setup">
<title>Administrator Level Setup</title>
<para>Verify that the user's login class in
<filename>/etc/login.conf</filename> sets the correct
language:</para>
<programlisting><replaceable>language_name</replaceable>|<replaceable>Account Type Description</replaceable>:\
:charset=<replaceable>MIME_charset</replaceable>:\
:lang=<replaceable>locale_name</replaceable>:\
:tc=default:</programlisting>
<para>The previous Latin-1 example would look like
this:</para>
<programlisting>german|German Users Accounts:\
:charset=ISO-8859-1:\
:lang=de_DE.ISO8859-1:\
:tc=default:</programlisting>
<para>Whenever this file is edited, execute the following
command to update the capability database:</para>
<screen>&prompt.root; <userinput>cap_mkdb /etc/login.conf</userinput></screen>
<bridgehead renderas="sect4">Changing Login Classes with
&man.vipw.8;</bridgehead>
<indexterm>
<primary><command>vipw</command></primary>
</indexterm>
<para>When using <command>vipw</command> to add new users,
use <replaceable>language</replaceable> to set the
language:</para>
<programlisting>user:password:1111:11:<replaceable>language</replaceable>:0:0:User Name:/home/user:/bin/sh</programlisting>
<bridgehead renderas="sect4">Changing Login Classes with
&man.adduser.8;</bridgehead>
<indexterm>
<primary><command>adduser</command></primary>
</indexterm>
<indexterm><primary>login class</primary></indexterm>
<para>When using <command>adduser</command> to add new
users, configure the language as follows:</para>
<itemizedlist>
<listitem>
<para>If all new users use the same language, set
<literal>defaultclass =
<replaceable>language</replaceable></literal> in
<filename>/etc/adduser.conf</filename>.</para>
</listitem>
<listitem>
<para>Alternatively, input the specified language at
this prompt:
<screen><prompt>Enter login class: default []:</prompt></screen>
when creating a new user using
&man.adduser.8;.</para>
</listitem>
<listitem>
<para>Another alternative is to use the following
when creating a user that uses a different language
than the one set in
<filename>/etc/adduser.conf</filename>:</para>
<screen>&prompt.root; <userinput>adduser -class <replaceable>language</replaceable></userinput></screen>
</listitem>
</itemizedlist>
<bridgehead renderas="sect4">Changing Login Classes with
&man.pw.8;</bridgehead>
<indexterm>
<primary><command>pw</command></primary>
</indexterm>
<para>If &man.pw.8; is used to add new users, call
it in this form:</para>
<screen>&prompt.root; <userinput>pw useradd <replaceable>user_name</replaceable> -L <replaceable>language</replaceable></userinput></screen>
</sect5>
</sect4>
<sect4 id="startup-file">
<title>Shell Startup File Method</title>
<note>
<para>This method is not recommended because it requires
a different setup for each shell. Use the <link
linkend="login-class">Login Class Method</link>
instead.</para>
</note>
<indexterm><primary>MIME</primary></indexterm>
<indexterm><primary>locale</primary></indexterm>
<para>To add the locale name and MIME character set, set
the two environment variables shown below in the
<filename>/etc/profile</filename> or
<filename>/etc/csh.login</filename> shell startup files.
This example sets the German language:</para>
<para>In <filename>/etc/profile</filename>:</para>
<programlisting><envar>LANG=de_DE.ISO8859-1; export LANG</envar>
<envar>MM_CHARSET=ISO-8859-1; export MM_CHARSET</envar></programlisting>
<para>Or in <filename>/etc/csh.login</filename>:</para>
<programlisting><envar>setenv LANG de_DE.ISO8859-1</envar>
<envar>setenv MM_CHARSET ISO-8859-1</envar></programlisting>
<para>Alternatively, add the above settings to
<filename>/usr/share/skel/dot.profile</filename> or
<filename>/usr/share/skel/dot.login</filename>.</para>
<para>To configure <application>Xorg</application>, add
<emphasis>one</emphasis> of the following to
<filename>~/.xinitrc</filename>, depending upon the
shell:</para>
<programlisting><envar>LANG=de_DE.ISO8859-1; export LANG</envar></programlisting>
<programlisting><envar>setenv LANG de_DE.ISO8859-1</envar></programlisting>
</sect4>
</sect3>
</sect2>
<sect2 id="setting-console">
<title>Console Setup</title>
<para>For all single C chars character sets, set the correct
console fonts in <filename>/etc/rc.conf</filename> for the
language in question with:</para>
<programlisting>font8x16=<replaceable>font_name</replaceable>
font8x14=<replaceable>font_name</replaceable>
font8x8=<replaceable>font_name</replaceable></programlisting>
<para>The <replaceable>font_name</replaceable> is taken from
<filename
class="directory">/usr/share/syscons/fonts</filename>,
without the <filename>.fnt</filename> suffix.</para>
<indexterm>
<primary><application>sysinstall</application></primary>
</indexterm>
<indexterm><primary>keymap</primary></indexterm>
<indexterm><primary>screenmap</primary></indexterm>
<para>The keymap and screenmap for the single C chars character
set can be set using <command>sysinstall</command>. Once
inside <application>sysinstall</application>, choose
<guimenuitem>Configure</guimenuitem>, then
<guimenuitem>Console</guimenuitem>. Alternatively,
add the following to <filename>/etc/rc.conf</filename>:</para>
<programlisting>scrnmap=<replaceable>screenmap_name</replaceable>
keymap=<replaceable>keymap_name</replaceable>
keychange="<replaceable>fkey_number sequence</replaceable>"</programlisting>
<para>The <replaceable>screenmap_name</replaceable> is taken
from <filename
class="directory">/usr/share/syscons/scrnmaps</filename>,
without the <filename>.scm</filename> suffix. A screenmap
with a corresponding mapped font is usually needed as a
workaround for expanding bit 8 to bit 9 on a VGA adapter's
font character matrix. This will move letters out of the
pseudographics area if the screen font uses a bit 8
column.</para>
<para>If <application>moused</application> is enabled in
<filename>/etc/rc.conf</filename>, review the mouse cursor
information in the next paragraph.</para>
<indexterm>
<primary><application>moused</application></primary>
</indexterm>
<para>By default, the mouse cursor of the &man.syscons.4; driver
occupies the 0xd0-0xd3 range in the character set. If the
language uses this range, move the cursor's range. To enable
this workaround for &os;, add the following line to
<filename>/etc/rc.conf</filename>:</para>
<programlisting>mousechar_start=3</programlisting>
<para>The <replaceable>keymap_name</replaceable> in the above
example is taken from <filename
class="directory">/usr/share/syscons/keymaps</filename>,
without the <filename>.kbd</filename> suffix. When uncertain
as to which keymap to use, &man.kbdmap.1; can be used to test
keymaps without rebooting.</para>
<para>The <literal>keychange</literal> is usually needed to
program function keys to match the selected terminal type
because function key sequences cannot be defined in the key
map.</para>
<para>Be sure to set the correct console terminal type in
<filename>/etc/ttys</filename> for all virtual terminal
entries. Current pre-defined correspondences are:</para>
<informaltable frame="none" pgwide="1">
<tgroup cols="2">
<thead>
<row>
<entry>Character Set</entry>
<entry>Terminal Type</entry>
</row>
</thead>
<tbody>
<row>
<entry>ISO8859-1 or ISO8859-15</entry>
<entry><literal>cons25l1</literal></entry>
</row>
<row>
<entry>ISO8859-2</entry>
<entry><literal>cons25l2</literal></entry>
</row>
<row>
<entry>ISO8859-7</entry>
<entry><literal>cons25l7</literal></entry>
</row>
<row>
<entry>KOI8-R</entry>
<entry><literal>cons25r</literal></entry>
</row>
<row>
<entry>KOI8-U</entry>
<entry><literal>cons25u</literal></entry>
</row>
<row>
<entry>CP437 (VGA default)</entry>
<entry><literal>cons25</literal></entry>
</row>
<row>
<entry>US-ASCII</entry>
<entry><literal>cons25w</literal></entry>
</row>
</tbody>
</tgroup>
</informaltable>
<para>For languages with wide or multibyte characters, use the
correct &os; port in <filename
class="directory">/usr/ports/<replaceable>language</replaceable></filename>.
Some applications appear as serial terminals to the system.
Reserve enough terminals in <filename>/etc/ttys</filename>
for both <application>Xorg</application> and the pseudo-serial
console. Here is a partial list of applications for using
other languages in the console:</para>
<informaltable frame="none" pgwide="1">
<tgroup cols="2">
<thead>
<row>
<entry>Language</entry>
<entry>Location</entry>
</row>
</thead>
<tbody>
<row>
<entry>Traditional Chinese (BIG-5)</entry>
<entry><filename
role="package">chinese/big5con</filename></entry>
</row>
<row>
<entry>Japanese</entry>
<entry><filename
role="package">japanese/kon2-16dot</filename> or
<filename
role="package">japanese/mule-freewnn</filename></entry>
</row>
<row>
<entry>Korean</entry>
<entry><filename
role="package">korean/han</filename></entry>
</row>
</tbody>
</tgroup>
</informaltable>
</sect2>
<sect2>
<title>Xorg Setup</title>
<para>Although <application>Xorg</application> is not installed
with &os;, it can be installed from the Ports Collection.
Refer to <xref linkend="x11"/> for more information on
how to do this. This section discusses how to localize
<application>Xorg</application> once it is installed.</para>
<para>Application specific <acronym>i18n</acronym> settings such
as fonts and menus can be tuned in
<filename>~/.Xresources</filename>.</para>
<sect3>
<title>Displaying Fonts</title>
<indexterm><primary>Xorg True Type font
server</primary></indexterm>
<para>After installing <filename
role="package">x11-servers/xorg-server</filename>, install
the language's &truetype; fonts. Setting the correct locale
should allow users to view their selected language in
graphical application menus.</para>
</sect3>
<sect3>
<title>Inputting Non-English Characters</title>
<indexterm><primary>X Input Method
(XIM)</primary></indexterm>
<para>The X Input Method (<acronym>XIM</acronym>) protocol
is an input standard for <application>Xorg</application>
clients. All <application>Xorg</application> applications
should be written as XIM clients that take input from XIM
input servers. There are several XIM servers available for
different languages.</para>
</sect3>
</sect2>
<sect2>
<title>Printer Setup</title>
<para>Some single C chars character sets are hardware coded
into printers. Wide or multibyte character sets require
special setup using a utility such as
<application>apsfilter</application>. Documents can be
converted to &postscript; or PDF formats using language
specific converters.</para>
</sect2>
<sect2>
<title>Kernel and File Systems</title>
<para>The &os; fast filesystem (<acronym>FFS</acronym>) is 8-bit
clean, so it can be used with any single C chars character
set. However, character set names are not stored in the
filesystem as it is raw 8-bit and does not understand encoding
order. Officially, <acronym>FFS</acronym> does not support
any form of wide or multibyte character sets. However, some
wide or multibyte character sets have independent patches for
enabling support on <acronym>FFS</acronym>. Refer to the
respective languages' web sites for more information and the
patch files.</para>
<indexterm><primary>DOS</primary></indexterm>
<indexterm><primary>Unicode</primary></indexterm>
<para>&os;'s support for the &ms-dos; filesystem has the
configurable ability to convert between &ms-dos;, Unicode
character sets, and chosen &os; filesystem character sets.
Refer to &man.mount.msdosfs.8; for details.</para>
</sect2>
</sect1>
<sect1 id="l10n-compiling">
<title>Compiling <acronym>i18n</acronym> Programs</title>
<para>Many applications in the &os; Ports Collection have been
ported with <acronym>i18n</acronym> support. Some of these
include <literal>-i18n</literal> in the port name. These
and many other programs have built in support for
<acronym>i18n</acronym> and need no special
consideration.</para>
<indexterm>
<primary><application>MySQL</application></primary>
</indexterm>
<para>However, some applications such as
<application>MySQL</application> need to have their
<filename>Makefile</filename> configured with the specific
charset. This is usually done in the port's
<filename>Makefile</filename> or by passing a value to
<application>configure</application> in the source.</para>
</sect1>
<sect1 id="lang-setup">
<title>Localizing &os; to Specific Languages</title>
<sect2 id="ru-localize">
<sect2info>
<authorgroup>
<author>
<firstname>Andrey</firstname>
<surname>Chernov</surname>
<contrib>Originally contributed by </contrib>
</author>
</authorgroup>
</sect2info>
<title>Russian Language (KOI8-R Encoding)</title>
<indexterm>
<primary>localization</primary>
<secondary>Russian</secondary>
</indexterm>
<para>For more information about KOI8-R encoding, refer to
<ulink url="http://koi8.pp.ru/">KOI8-R References
(Russian Net Character Set)</ulink>.</para>
<sect3>
<title>Locale Setup</title>
<para>To set this locale, put the following lines into each
user's <filename>~/.login_conf</filename>:</para>
<programlisting>me:My Account:\
:charset=KOI8-R:\
:lang=ru_RU.KOI8-R:</programlisting>
</sect3>
<sect3>
<title>Console Setup</title>
<itemizedlist>
<listitem>
<para>Add the following lines to
<filename>/etc/rc.conf</filename>:</para>
<programlisting>keymap="ru.koi8-r"
scrnmap="koi8-r2cp866"
font8x16="cp866b-8x16"
font8x14="cp866-8x14"
font8x8="cp866-8x8"
mousechar_start=3</programlisting>
</listitem>
<listitem>
<para>For each <literal>ttyv</literal> entry in
<filename>/etc/ttys</filename>, use
<literal>cons25r</literal> as the terminal type.</para>
</listitem>
</itemizedlist>
</sect3>
<sect3>
<title>Printer Setup</title>
<indexterm><primary>printers</primary></indexterm>
<para>Since most printers with Russian characters come with
hardware code page CP866, a special output filter is needed
to convert from KOI8-R to CP866. &os; installs a default
filter as <filename>/usr/libexec/lpr/ru/koi2alt</filename>.
A Russian printer <filename>/etc/printcap</filename> entry
should look like:</para>
<programlisting>lp|Russian local line printer:\
:sh:of=/usr/libexec/lpr/ru/koi2alt:\
:lp=/dev/lpt0:sd=/var/spool/output/lpd:lf=/var/log/lpd-errs:</programlisting>
<para>Refer to &man.printcap.5; for a more detailed
description.</para>
</sect3>
<sect3>
<title>&ms-dos; and Russian Filenames</title>
<para>The following example &man.fstab.5; entry enables
support for Russian filenames in mounted &ms-dos;
filesystems:</para>
<programlisting>/dev/ad0s2 /dos/c msdos rw,-Lru_RU.KOI8-R 0 0</programlisting>
<para><option>-L</option> selects the locale name. Refer to
&man.mount.msdosfs.8; for more details.</para>
</sect3>
<sect3>
<title><application>Xorg</application> Setup</title>
<orderedlist>
<listitem>
<para>First, configure the <link
linkend="setting-locale">non-X locale
setup</link>.</para>
</listitem>
<listitem>
<para>When using <application>&xorg;</application>,
install the <filename
role="package">x11-fonts/xorg-fonts-cyrillic</filename>
package.</para>
<para>Check the <literal>"Files"</literal> section in
<filename>/etc/X11/xorg.conf</filename>. The
following line must be added <emphasis>before</emphasis>
any other <literal>FontPath</literal> entries:</para>
<programlisting>FontPath "/usr/local/lib/X11/fonts/cyrillic"</programlisting>
<note>
<para>Search the Ports Collection for more Cyrillic
fonts.</para>
</note>
</listitem>
<listitem>
<para>To activate a Russian keyboard, add the following
to the <literal>"Keyboard"</literal> section of
<filename>/etc/xorg.conf</filename>:</para>
<programlisting>Option "XkbLayout" "us,ru"
Option "XkbOptions" "grp:toggle"</programlisting>
<para>Make sure that <literal>XkbDisable</literal> is
commented out in that file.</para>
<para>For <literal>grp:toggle</literal> use <keycap>Right
Alt</keycap>, for
<literal>grp:ctrl_shift_toggle</literal> use <keycombo
action="simul"><keycap>Ctrl</keycap><keycap>Shift</keycap></keycombo>.
For <literal>grp:caps_toggle</literal> use
<keycap>CapsLock</keycap>. The old
<keycap>CapsLock</keycap> function is still available
in LAT mode only using <keycombo
action="simul"><keycap>Shift</keycap><keycap>CapsLock</keycap></keycombo>.
<literal>grp:caps_toggle</literal>
does not work in <application>&xorg;</application> for
some unknown reason.</para>
<para>If the keyboard has <quote>&windows;</quote> keys,
and some non-alphabetical keys are mapped incorrectly,
add the following line to
<filename>/etc/xorg.conf</filename>:</para>
<programlisting>Option "XkbVariant" ",winkeys"</programlisting>
<note>
<para>The Russian XKB keyboard may not work with
non-localized applications.</para>
</note>
</listitem>
</orderedlist>
<note>
<para>Minimally localized applications should call a
<function>XtSetLanguageProc (NULL, NULL, NULL);</function>
function early in the program.</para>
<para>See <ulink url="http://koi8.pp.ru/xwin.html">
KOI8-R for X Window</ulink> for more instructions on
localizing <application>Xorg</application>
applications.</para>
</note>
</sect3>
</sect2>
<sect2>
<title>Traditional Chinese Localization for Taiwan</title>
<indexterm>
<primary>localization</primary>
<secondary>Traditional Chinese</secondary>
</indexterm>
<para>The &os;-Taiwan Project has a Chinese HOWTO for
&os; at <ulink
url="http://netlab.cse.yzu.edu.tw/~statue/freebsd/zh-tut/"></ulink>
using many Chinese ports. The current editor for the
<literal>&os; Chinese HOWTO</literal> is Shen Chuan-Hsing
<email>statue@freebsd.sinica.edu.tw</email>.</para>
</sect2>
<sect2>
<title>German Language Localization for All ISO 8859-1
Languages</title>
<indexterm>
<primary>localization</primary>
<secondary>German</secondary>
</indexterm>
<para>Slaven Rezic <email>eserte@cs.tu-berlin.de</email> wrote a
tutorial on using umlauts on &os;. The tutorial
is written in German and is available at <ulink
url="http://user.cs.tu-berlin.de/~eserte/FreeBSD/doc/umlaute/umlaute.html"></ulink>.</para>
</sect2>
<sect2>
<title>Greek Language Localization</title>
<indexterm>
<primary>localization</primary>
<secondary>Greek</secondary>
</indexterm>
<para>Nikos Kokkalis <email>nickkokkalis@gmail.com</email> has
written a complete article on Greek support in &os;. It is
available <ulink
url="&url.doc.base;/el_GR.ISO8859-7/articles/greek-language-
support/ index.html">here</ulink>, in Greek only, as part of
the official &os; Greek documentation.</para>
</sect2>
<sect2>
<title>Japanese and Korean Language Localization</title>
<indexterm>
<primary>localization</primary>
<secondary>Japanese</secondary>
</indexterm>
<indexterm>
<primary>localization</primary>
<secondary>Korean</secondary>
</indexterm>
<para>For Japanese, refer to
<ulink url="http://www.jp.FreeBSD.org/"></ulink>,
and for Korean, refer to
<ulink url="http://www.kr.FreeBSD.org/"></ulink>.</para>
</sect2>
<sect2>
<title>Non-English &os; Documentation</title>
<para>Some &os; contributors have translated parts of the
&os; documentation to other languages. They are available
through links on the <ulink
url="&url.base;/index.html">main site</ulink> or in
<filename class="directory">/usr/share/doc</filename>.</para>
</sect2>
</sect1>
</chapter>
|