Put in remaining pages and wiki contents.
[ikiwiki.git] / docs / handbook / handbook-using-localization.mdwn
1 \r
2 ----\r
3 \r
4 ## 14.3 Using Localization \r
5 \r
6 In all its splendor, I18N is not DragonFly-specific and is a convention. We encourage you to help DragonFly in following this convention.\r
7 \r
8 Localization settings are based on three main terms: Language Code, Country Code, and Encoding. Locale names are constructed from these parts as follows:\r
9 \r
10     \r
11     LanguageCode_CountryCode.Encoding\r
12 \r
13 \r
14 ### 14.3.1 Language and Country Codes \r
15 \r
16 In order to localize a DragonFly system to a specific language (or any other I18N-supporting UNIX® like systems), the user needs to find out the codes for the specify country and language (country codes tell applications what variation of given language to use). In addition, web browsers, SMTP/POP servers, web servers, etc. make decisions based on them. The following are examples of language/country codes:\r
17 \r
18 [[!table  data="""
19 | Language/Country Code | Description 
20  en_US | English - United States 
21  ru_RU | Russian for Russia 
22  zh_TW | Traditional Chinese for Taiwan |\r
23 """]]\r
24 ### 14.3.2 Encodings \r
25 \r
26 Some languages use non-ASCII encodings that are 8-bit, wide or multibyte characters, see [multibyte(3)](http://leaf.dragonflybsd.org/cgi/web-man?command#multibyte&section3) for more details. Older applications do not recognize them and mistake them for control characters. Newer applications usually do recognize 8-bit characters. Depending on the implementation, users may be required to compile an application with wide or multibyte characters support, or configure it correctly.\r
27 \r
28 Specifically, the user needs to look at the application documentation to decide on how to configure it correctly or to pass correct values into the configure/Makefile/compiler.\r
29 \r
30 Some things to keep in mind are:\r
31 \r
32
33 * Language specific single C chars character sets (see [multibyte(3)](http://leaf.dragonflybsd.org/cgi/web-man?command#multibyte&;section3)), e.g. ISO-8859-1, ISO-8859-15, KOI8-R, CP437.\r
34
35 * Wide or multibyte encodings, e.g. EUC, Big5.\r
36 \r
37 You can check the active list of character sets at the [IANA Registry](http://www.iana.org/assignments/character-sets).\r
38 \r
39  **Note:** DragonFly uses X11-compatible locale encodings instead.\r
40 \r
41 ### 14.3.3 Setting Locale \r
42 \r
43 Usually it is sufficient to export the value of the locale name as `LANG` in the login shell. This could be done in the user's `~/.login_conf` file or in the startup file of the user's shell (`~/.profile`, `~/.bashrc`, `~/.cshrc`). There is no need to set the locale subsets such as `LC_CTYPE`, `LC_CTIME`. Please refer to language-specific DragonFly documentation for more information.\r
44 \r
45 You should set the following two environment variables in your configuration files:\r
46 \r
47
48 * `LANG` for POSIX® [setlocale(3)](http://leaf.dragonflybsd.org/cgi/web-man?command#setlocale&section3) family functions\r
49
50 * `MM_CHARSET` for applications' MIME character set\r
51 \r
52 This includes the user shell configuration, the specific application configuration, and the X11 configuration.\r
53 \r
54 #### 14.3.3.1 Setting Locale Methods \r
55 \r
56 There are two methods for setting locale, and both are described below. The first (recommended one) is by assigning the environment variables in [login class](using-localization.html#LOGIN-CLASS), and the second is by adding the environment variable assignments to the system's shell [startup file](using-localization.html#STARTUP-FILE).\r
57 \r
58 ##### 14.3.3.1.1 Login Classes Method \r
59 \r
60 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. [User Level Setup](using-localization.html#USR-SETUP) can be done by an user himself and [Administrator Level Setup](using-localization.html#ADM-SETUP) require superuser privileges.\r
61 \r
62 ###### 14.3.3.1.1.1 User Level Setup \r
63 \r
64 Here is a minimal example of a `.login_conf` file in user's home directory which has both variables set for Latin-1 encoding:\r
65 \r
66     \r
67     me:\\r
68         :charset=ISO-8859-1:\\r
69         :lang=de_DE.ISO8859-1:\r
70 \r
71 \r
72 Here is an example of a `.login_conf` that sets the variables for Traditional Chinese in BIG-5 encoding. Notice the many more variables set because some software does not respect locale variables correctly for Chinese, Japanese, and Korean.\r
73 \r
74     \r
75     #Users who do not wish to use monetary units or time formats\r
76     #of Taiwan can manually change each variable\r
77     me:\\r
78         :lang=zh_TW.Big5:\\r
79         :lc_all=zh_TW.Big:\\r
80         :lc_collate=zh_TW.Big5:\\r
81         :lc_ctype=zh_TW.Big5:\\r
82         :lc_messages=zh_TW.Big5:\\r
83         :lc_monetary=zh_TW.Big5:\\r
84         :lc_numeric=zh_TW.Big5:\\r
85         :lc_time=zh_TW.Big5:\\r
86         :charset=big5:\\r
87         :xmodifiers#"@imxcin": #Setting the XIM Input Server\r
88 \r
89 \r
90 See [Administrator Level Setup](using-localization.html#ADM-SETUP) and [login.conf(5)](http://leaf.dragonflybsd.org/cgi/web-man?command#login.conf&section5) for more details.\r
91 \r
92 ###### 14.3.3.1.1.2 Administrator Level Setup \r
93 \r
94 Verify that the user's login class in `/etc/login.conf` sets the correct language. Make sure these settings appear in `/etc/login.conf`:\r
95 \r
96     \r
97     language_name:accounts_title:\\r
98         :charset=MIME_charset:\\r
99         :lang=locale_name:\\r
100         :tc=default:\r
101 \r
102 \r
103 So sticking with our previous example using Latin-1, it would look like this:\r
104 \r
105     \r
106     german:German Users Accounts:\\r
107         :charset=ISO-8859-1:\\r
108         :lang=de_DE.ISO8859-1:\\r
109         :tc=default:\r
110 \r
111 \r
112 ##### Changing Login Classes with [vipw(8)](http://leaf.dragonflybsd.org/cgi/web-man?command=vipw&section=8) \r
113 \r
114 Use `vipw` to add new users, and make the entry look like this:\r
115 \r
116     \r
117     user:password:1111:11: language :0:0:User Name:/home/user:/bin/sh\r
118 \r
119 \r
120 ##### Changing Login Classes with [adduser(8)](http://leaf.dragonflybsd.org/cgi/web-man?command=adduser&section=8) \r
121 \r
122 Use `adduser` to add new users, and do the following:\r
123 \r
124
125 * Set `defaultclass = language` in `/etc/adduser.conf`. Keep in mind you must enter a `default` class for all users of other languages in this case.\r
126
127 * An alternative variant is answering the specified language each time that\r
128       \r
129       Enter login class: default []:\r
130   \r
131    appears from [adduser(8)](http://leaf.dragonflybsd.org/cgi/web-man?command#adduser&section8).\r
132
133 * Another alternative is to use the following for each user of a different language that you wish to add:\r
134       \r
135       # adduser -class language\r
136   \r
137 \r
138 ##### Changing Login Classes with [pw(8)](http://leaf.dragonflybsd.org/cgi/web-man?command=pw&section=8) \r
139 \r
140 If you use [pw(8)](http://leaf.dragonflybsd.org/cgi/web-man?command#pw&;section8) for adding new users, call it in this form:\r
141 \r
142     \r
143     # pw useradd user_name -L language\r
144 \r
145 \r
146 ##### 14.3.3.1.2 Shell Startup File Method \r
147 \r
148  **Note:** This method is not recommended because it requires a different setup for each possible shell program chosen. Use the [Login Class Method](using-localization.html#LOGIN-CLASS) instead.\r
149 \r
150 To add the locale name and MIME character set, just set the two environment variables shown below in the `/etc/profile` and/or `/etc/csh.login` shell startup files. We will use the German language as an example below:\r
151 \r
152 In `/etc/profile`:\r
153 \r
154     \r
155     LANG=de_DE.ISO8859-1; export LANG\r
156     MM_CHARSET=ISO-8859-1; export MM_CHARSET\r
157 \r
158 \r
159 Or in `/etc/csh.login`:\r
160 \r
161     \r
162     setenv LANG de_DE.ISO8859-1\r
163     setenv MM_CHARSET ISO-8859-1\r
164 \r
165 \r
166 Alternatively, you can add the above instructions to `/usr/share/skel/dot.profile` (similar to what was used in `/etc/profile` above), or `/usr/share/skel/dot.login` (similar to what was used in `/etc/csh.login` above).\r
167 \r
168 For X11:\r
169 \r
170 In `$HOME/.xinitrc`:\r
171 \r
172     \r
173     LANG=de_DE.ISO8859-1; export LANG\r
174 \r
175 \r
176 Or:\r
177 \r
178     \r
179     setenv LANG de_DE.ISO8859-1\r
180 \r
181 \r
182 Depending on your shell (see above).\r
183 \r
184 ### 14.3.4 Console Setup \r
185 \r
186 For all single C chars character sets, set the correct console fonts in `/etc/rc.conf` for the language in question with:\r
187 \r
188     \r
189     font8x16=font_name\r
190     font8x14=font_name\r
191     font8x8=font_name\r
192 \r
193 \r
194 The `font_name` here is taken from the `/usr/share/syscons/fonts` directory, without the `.fnt` suffix.\r
195 \r
196 Also be sure to set the correct keymap and screenmap for your single C chars character set. You can add the following to `/etc/rc.conf`:\r
197 \r
198     \r
199     scrnmap=screenmap_name\r
200     keymap=keymap_name\r
201     keychange="fkey_number sequence"\r
202 \r
203 \r
204 The `screenmap_name` here is taken from the `/usr/share/syscons/scrnmaps` directory, without the `.scm` 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 in pseudographics area, i.e., to move letters out of that area if screen font uses a bit 8 column.\r
205 \r
206 If you have the  **moused**  daemon enabled by setting the following in your `/etc/rc.conf`:\r
207 \r
208     \r
209     moused_enable="YES"\r
210 \r
211 \r
212 then examine the mouse cursor information in the next paragraph.\r
213 \r
214 By default the mouse cursor of the [syscons(4)](http://leaf.dragonflybsd.org/cgi/web-man?command#syscons&section4) driver occupies the 0xd0-0xd3 range in the character set. If your language uses this range, you need to move the cursor's range outside of it. To enable this workaround, insert the following line into your kernel configuration:\r
215 \r
216     \r
217     options             SC_MOUSE_CHAR=0x03\r
218 \r
219 \r
220 Insert the following line into `/etc/rc.conf`:\r
221 \r
222     \r
223     mousechar_start=3\r
224 \r
225 \r
226 The `keymap_name` here is taken from the `/usr/share/syscons/keymaps` directory, without the `.kbd` suffix. If you're uncertain which keymap to use, you use can [kbdmap(1)](http://leaf.dragonflybsd.org/cgi/web-man?command#kbdmap&section1) to test keymaps without rebooting.\r
227 \r
228 The `keychange` is usually needed to program function keys to match the selected terminal type because function key sequences cannot be defined in the key map.\r
229 \r
230 Also be sure to set the correct console terminal type in `/etc/ttys` for all `ttyv*` entries. Current pre-defined correspondences are:\r
231 \r
232 [[!table  data="""
233 | Character Set | Terminal Type 
234  ISO-8859-1 or ISO-8859-15 | `cons25l1` 
235  ISO-8859-2 | `cons25l2` 
236  ISO-8859-7 | `cons25l7` 
237  KOI8-R | `cons25r` 
238  KOI8-U | `cons25u` 
239  CP437 (VGA default) | `cons25` 
240  US-ASCII | `cons25w` |\r
241 """]]\r
242 \r
243 ### 14.3.5 X11 Setup \r
244 \r
245 Although X11 is not part of DragonFly, we have included some information here for DragonFly users. For more details, refer to the [XFree86™ web site](http://www.xfree86.org/) or whichever X11 Server you use.\r
246 \r
247 In `~/.Xresources`, you can additionally tune application specific I18N settings (e.g., fonts, menus, etc.).\r
248 \r
249 #### 14.3.5.1 Displaying Fonts \r
250 \r
251 Install the X11 TrueType® Common server ([x11-servers/XttXF86srv-common](http://pkgsrc.se/x11-servers/XttXF86srv-common)) and install the language TrueType fonts. Setting the correct locale should allow you to view your selected language in menus and such.\r
252 \r
253 #### 14.3.5.2 Inputting Non-English Characters \r
254 \r
255 The X11 Input Method (XIM) Protocol is a new standard for all X11 clients. All X11 applications should be written as XIM clients that take input from XIM Input servers. There are several XIM servers available for different languages.\r
256 \r
257 ### 14.3.6 Printer Setup \r
258 \r
259 Some single C chars character sets are usually hardware coded into printers. Wide or multibyte character sets require special setup and we recommend using  **apsfilter** . You may also convert the document to PostScript® or PDF formats using language specific converters.\r
260 \r
261 ### 14.3.7 Kernel and File Systems \r
262 \r
263 The DragonFly fast filesystem (FFS) is 8-bit clean, so it can be used with any single C chars character set (see [multibyte(3)](http://leaf.dragonflybsd.org/cgi/web-man?command#multibyte&section3)), but there is no character set name stored in the filesystem; i.e., it is raw 8-bit and does not know anything about encoding order. Officially, FFS does not support any form of wide or multibyte character sets yet. However, some wide or multibyte character sets have independent patches for FFS enabling such support. They are only temporary unportable solutions or hacks and we have decided to not include them in the source tree. Refer to respective languages' web sites for more informations and the patch files.\r
264 \r
265 The DragonFly MS-DOS® filesystem has the configurable ability to convert between MS-DOS, Unicode character sets and chosen DragonFly filesystem character sets. See [mount_msdos(8)](http://leaf.dragonflybsd.org/cgi/web-man?command#mount_msdos&section8) for details.\r
266 \r
267 ----\r
268 \r
269 \r