]> pere.pagekite.me Git - homepage.git/blob - linux/glibc/howto.html
Split regex for yes and no.
[homepage.git] / linux / glibc / howto.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2 <html lang="en">
3 <head>
4 <title>How to write a GNU libc locale</title>
5 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
6 <meta http-equiv="Content-Language" content="en">
7 <link rel="stylesheet" type="text/css" href="http://i18n.skolelinux.no/stilsett.css" id="nn1">
8 <link rel="stylesheet" type="text/css" href="http://i18n.skolelinux.no/utskrift.css" media="print" id="nn2">
9
10 </head>
11
12 <body>
13 <div class="topp">
14 <h1>How to write a GNU libc locale</h1>
15 </div>
16
17 <div class="meny">
18 <a href="./">Back</a>
19 </div>
20
21 <div class="hovuddel">
22
23 <p>This is a draft document explaining how to write locale files
24 for GNU libc. It will not go into details, but reference
25 specifications. It will on the other hand mention some of the
26 pitfalls, and try to document the current practice.</p>
27
28 <h2>How to choose the locale file name</h2>
29
30 <p>Locale names consist of three parts. The language code, the
31 country/region code, and the optional modifier. The format is
32 language_REGION@modifier. The language code is a code from
33 ISO 639. The two-letter code is prefered, but a three letter
34 code is accepted if no two-letter code is available. The
35 country/region code is a code from ISO 3166. If the language
36 or region in question is missing in the ISO standard, one need
37 to get the ISO standard updated before the locale will be
38 included in glibc. If one can't convince the ISO 639
39 maintainers that your language exists (and thus need a
40 language code), the glibc maintainers will refuse to add the
41 locale. In addition, the glibc maintainers seem to refuse
42 "artificial languages" like Esperanto and Lojban, even if they
43 got a ISO 639 code.</p>
44
45 <p>Little is known about the requirements for the naming of
46 modifiers. The following modifiers are currently used:
47 abegede, cyrillic, euro and saaho. This might indicate that
48 lower case letters are prefered in modifier names.</p>
49
50 <p>It is recommended to follow RFC 3066 when selecting locale
51 names.</p>
52
53 <ul>
54
55 <li><a href="http://www.unicode.org/onlinedat/countries.html">ISO
56 3166</a></li>
57
58 <li><a href="http://www.loc.gov/standards/iso639-2/">ISO 639</a></li>
59
60 <li><a href="http://rfc.sunsite.dk/rfc/rfc3066.html"> RFC 3066
61 - Tags for the Identification of Languages</a></li>
62
63 </ul>
64
65 <h2>Category order</h2>
66
67 <p>To make it easier to compare locales with each other, I
68 recommend using the same order for the categories in all
69 locales. Any order will do, so I picked the order used in most
70 locales, and decided to recommend this order:</p>
71
72 <ol>
73 <li>LC_IDENTIFICATION
74 <li>LC_CTYPE
75 <li>LC_COLLATE
76 <li>LC_MONETARY
77 <li>LC_NUMERIC
78 <li>LC_TIME
79 <li>LC_MESSAGES
80 <li>LC_PAPER
81 <li>LC_NAME
82 <li>LC_ADDRESS
83 <li>LC_TELEPHONE
84 <li>LC_MEASUREMENT
85 </ol>
86
87 <h2>Reuse when possible</h2>
88
89 <p>One should avoid cut-n-paste when possible, and instead use
90 the <tt>copy</tt> statement to include sections from locales
91 with identical content.</p>
92
93 <h2>LD_IDENTIFICATION</h2>
94
95 <p>The category entries are references to the standard used when
96 writing the given section. The standard refs should have
97 quotes around them, and should not use the &lt;U#&gt;
98 notation. They should normally look something like this:</p>
99
100 <blockquote><pre>
101 category "i18n:1997";LC_IDENTIFICATION
102 </pre></blockquote>
103
104 <h2>LC_MESSAGES</h2>
105
106 <p>Then yesexpr and noexpr entries should have the form
107 <tt>^[yY&lt;extra&gt;]</tt> and <tt>^[nN&lt;extra&gt;]</tt>,
108 without 0 and 1 and without trailing "<tt>.*</tt>".</p>
109
110 <h2>Standard documents and specifications</h2>
111
112 <h2>Testing the new locale file</h2>
113
114 <p>To test a new locale on a test machine, do the
115 following:</p>
116
117 <ul>
118
119 <li>Copy the new locale to
120 <tt>/usr/share/i18n/locales/<em>filename</em></tt></li>
121
122 <li>Run <tt>localedef -i <em>inputfile</em> -c -f
123 <em>charset<em> <em>locale</em></tt> to generate a
124 binary locale file in
125 <tt>/usr/lib/locale/<em>locale</em>/</tt></li>
126
127 <li>Test it using LANG=<em>locale</em>, for example by
128 running <tt>date</tt></li>
129
130 </ul>
131
132 <p>Example, generating a new <tt>de_DE@euro</tt> locale using
133 the ISO-8859-15 charset and save it as 'de_DE':</p>
134
135 <pre>
136 cp de_DE@euro /usr/share/i18n/locales/de_DE@euro
137 localedef -i de_DE@euro -c -f ISO-8859-15 de_DE
138 LANG=de_DE date
139 </pre>
140
141 </div>
142
143 <hr>
144 <address><a href="mailto:pere@hungry.com">Petter Reinholdtsen</a></address>
145 <!-- Created: Sun Mar 21 18:14:42 CET 2004 -->
146 <!-- hhmts start -->
147 Last modified: Sat Oct 30 02:03:59 CEST 2004
148 <!-- hhmts end -->
149 </body>
150 </html>