Install gettext-0.18.1.1.tar.gz
[msysgit.git] / mingw / share / doc / gettext / gettext_2.html
blob2da88d0fb999b93b8591c8ec10f8aa9985dc874d
1 <HTML>
2 <HEAD>
3 <!-- This HTML file has been created by texi2html 1.52b
4 from gettext.texi on 6 June 2010 -->
6 <META HTTP-EQUIV="content-type" CONTENT="text/html; charset=UTF-8">
7 <TITLE>GNU gettext utilities - 2 The User's View</TITLE>
8 </HEAD>
9 <BODY>
10 Go to the <A HREF="gettext_1.html">first</A>, <A HREF="gettext_1.html">previous</A>, <A HREF="gettext_3.html">next</A>, <A HREF="gettext_25.html">last</A> section, <A HREF="gettext_toc.html">table of contents</A>.
11 <P><HR><P>
14 <H1><A NAME="SEC7" HREF="gettext_toc.html#TOC7">2 The User's View</A></H1>
16 <P>
17 Nowadays, when users log into a computer, they usually find that all
18 their programs show messages in their native language -- at least for
19 users of languages with an active free software community, like French or
20 German; to a lesser extent for languages with a smaller participation in
21 free software and the GNU project, like Hindi and Filipino.
23 </P>
24 <P>
25 How does this work? How can the user influence the language that is used
26 by the programs? This chapter will answer it.
28 </P>
32 <H2><A NAME="SEC8" HREF="gettext_toc.html#TOC8">2.1 Operating System Installation</A></H2>
34 <P>
35 The default language is often already specified during operating system
36 installation. When the operating system is installed, the installer
37 typically asks for the language used for the installation process and,
38 separately, for the language to use in the installed system. Some OS
39 installers only ask for the language once.
41 </P>
42 <P>
43 This determines the system-wide default language for all users. But the
44 installers often give the possibility to install extra localizations for
45 additional languages. For example, the localizations of KDE (the K
46 Desktop Environment) and OpenOffice.org are often bundled separately,
47 as one installable package per language.
49 </P>
50 <P>
51 At this point it is good to consider the intended use of the machine: If
52 it is a machine designated for personal use, additional localizations are
53 probably not necessary. If, however, the machine is in use in an
54 organization or company that has international relationships, one can
55 consider the needs of guest users. If you have a guest from abroad, for
56 a week, what could be his preferred locales? It may be worth installing
57 these additional localizations ahead of time, since they cost only a bit
58 of disk space at this point.
60 </P>
61 <P>
62 The system-wide default language is the locale configuration that is used
63 when a new user account is created. But the user can have his own locale
64 configuration that is different from the one of the other users of the
65 same machine. He can specify it, typically after the first login, as
66 described in the next section.
68 </P>
71 <H2><A NAME="SEC9" HREF="gettext_toc.html#TOC9">2.2 Setting the Locale Used by GUI Programs</A></H2>
73 <P>
74 The immediately available programs in a user's desktop come from a group
75 of programs called a “desktop environment”; it usually includes the window
76 manager, a web browser, a text editor, and more. The most common free
77 desktop environments are KDE, GNOME, and Xfce.
79 </P>
80 <P>
81 The locale used by GUI programs of the desktop environment can be specified
82 in a configuration screen called “control center”, “language settings”
83 or “country settings”.
85 </P>
86 <P>
87 Individual GUI programs that are not part of the desktop environment can
88 have their locale specified either in a settings panel, or through environment
89 variables.
91 </P>
92 <P>
93 For some programs, it is possible to specify the locale through environment
94 variables, possibly even to a different locale than the desktop's locale.
95 This means, instead of starting a program through a menu or from the file
96 system, you can start it from the command-line, after having set some
97 environment variables. The environment variables can be those specified
98 in the next section (section <A HREF="gettext_2.html#SEC10">2.3 Setting the Locale through Environment Variables</A>); for some versions of
99 KDE, however, the locale is specified through a variable <CODE>KDE_LANG</CODE>,
100 rather than <CODE>LANG</CODE> or <CODE>LC_ALL</CODE>.
102 </P>
105 <H2><A NAME="SEC10" HREF="gettext_toc.html#TOC10">2.3 Setting the Locale through Environment Variables</A></H2>
108 As a user, if your language has been installed for this package, in the
109 simplest case, you only have to set the <CODE>LANG</CODE> environment variable
110 to the appropriate <SAMP>&lsquo;<VAR>ll</VAR>_<VAR>CC</VAR>&rsquo;</SAMP> combination. For example,
111 let's suppose that you speak German and live in Germany. At the shell
112 prompt, merely execute
113 <SAMP>&lsquo;setenv LANG de_DE&rsquo;</SAMP> (in <CODE>csh</CODE>),
114 <SAMP>&lsquo;export LANG; LANG=de_DE&rsquo;</SAMP> (in <CODE>sh</CODE>) or
115 <SAMP>&lsquo;export LANG=de_DE&rsquo;</SAMP> (in <CODE>bash</CODE>). This can be done from your
116 <TT>&lsquo;.login&rsquo;</TT> or <TT>&lsquo;.profile&rsquo;</TT> file, once and for all.
118 </P>
122 <H3><A NAME="SEC11" HREF="gettext_toc.html#TOC11">2.3.1 Locale Names</A></H3>
125 A locale name usually has the form <SAMP>&lsquo;<VAR>ll</VAR>_<VAR>CC</VAR>&rsquo;</SAMP>. Here
126 <SAMP>&lsquo;<VAR>ll</VAR>&rsquo;</SAMP> is an ISO 639 two-letter language code, and
127 <SAMP>&lsquo;<VAR>CC</VAR>&rsquo;</SAMP> is an ISO 3166 two-letter country code. For example,
128 for German in Germany, <VAR>ll</VAR> is <CODE>de</CODE>, and <VAR>CC</VAR> is <CODE>DE</CODE>.
129 You find a list of the language codes in appendix section <A HREF="gettext_17.html#SEC318">A Language Codes</A> and
130 a list of the country codes in appendix section <A HREF="gettext_18.html#SEC321">B Country Codes</A>.
132 </P>
134 You might think that the country code specification is redundant. But in
135 fact, some languages have dialects in different countries. For example,
136 <SAMP>&lsquo;de_AT&rsquo;</SAMP> is used for Austria, and <SAMP>&lsquo;pt_BR&rsquo;</SAMP> for Brazil. The country
137 code serves to distinguish the dialects.
139 </P>
141 Many locale names have an extended syntax
142 <SAMP>&lsquo;<VAR>ll</VAR>_<VAR>CC</VAR>.<VAR>encoding</VAR>&rsquo;</SAMP> that also specifies the character
143 encoding. These are in use because between 2000 and 2005, most users have
144 switched to locales in UTF-8 encoding. For example, the German locale on
145 glibc systems is nowadays <SAMP>&lsquo;de_DE.UTF-8&rsquo;</SAMP>. The older name <SAMP>&lsquo;de_DE&rsquo;</SAMP>
146 still refers to the German locale as of 2000 that stores characters in
147 ISO-8859-1 encoding -- a text encoding that cannot even accomodate the Euro
148 currency sign.
150 </P>
152 Some locale names use <SAMP>&lsquo;<VAR>ll</VAR>_<VAR>CC</VAR>.@<VAR>variant</VAR>&rsquo;</SAMP> instead of
153 <SAMP>&lsquo;<VAR>ll</VAR>_<VAR>CC</VAR>&rsquo;</SAMP>. The <SAMP>&lsquo;@<VAR>variant</VAR>&rsquo;</SAMP> can denote any kind of
154 characteristics that is not already implied by the language <VAR>ll</VAR> and
155 the country <VAR>CC</VAR>. It can denote a particular monetary unit. For example,
156 on glibc systems, <SAMP>&lsquo;de_DE@euro&rsquo;</SAMP> denotes the locale that uses the Euro
157 currency, in contrast to the older locale <SAMP>&lsquo;de_DE&rsquo;</SAMP> which implies the use
158 of the currency before 2002. It can also denote a dialect of the language,
159 or the script used to write text (for example, <SAMP>&lsquo;sr_RS@latin&rsquo;</SAMP> uses the
160 Latin script, whereas <SAMP>&lsquo;sr_RS&rsquo;</SAMP> uses the Cyrillic script to write Serbian),
161 or the orthography rules, or similar.
163 </P>
165 On other systems, some variations of this scheme are used, such as
166 <SAMP>&lsquo;<VAR>ll</VAR>&rsquo;</SAMP>. You can get the list of locales supported by your system
167 for your language by running the command <SAMP>&lsquo;locale -a | grep '^<VAR>ll</VAR>'&rsquo;</SAMP>.
169 </P>
171 There is also a special locale, called <SAMP>&lsquo;C&rsquo;</SAMP>.
172 When it is used, it disables all localization: in this locale, all programs
173 standardized by POSIX use English messages and an unspecified character
174 encoding (often US-ASCII, but sometimes also ISO-8859-1 or UTF-8, depending on
175 the operating system).
177 </P>
180 <H3><A NAME="SEC12" HREF="gettext_toc.html#TOC12">2.3.2 Locale Environment Variables</A></H3>
182 <A NAME="IDX40"></A>
183 <A NAME="IDX41"></A>
184 <A NAME="IDX42"></A>
186 </P>
188 A locale is composed of several <EM>locale categories</EM>, see section <A HREF="gettext_1.html#SEC4">1.3 Aspects in Native Language Support</A>.
189 When a program looks up locale dependent values, it does this according to
190 the following environment variables, in priority order:
192 </P>
194 <OL>
195 <LI><CODE>LANGUAGE</CODE>
197 <A NAME="IDX43"></A>
199 <A NAME="IDX44"></A>
200 <LI><CODE>LC_ALL</CODE>
202 <A NAME="IDX45"></A>
203 <A NAME="IDX46"></A>
204 <A NAME="IDX47"></A>
205 <A NAME="IDX48"></A>
206 <A NAME="IDX49"></A>
207 <A NAME="IDX50"></A>
208 <LI><CODE>LC_xxx</CODE>, according to selected locale category:
210 <CODE>LC_CTYPE</CODE>, <CODE>LC_NUMERIC</CODE>, <CODE>LC_TIME</CODE>, <CODE>LC_COLLATE</CODE>,
211 <CODE>LC_MONETARY</CODE>, <CODE>LC_MESSAGES</CODE>, ...
212 <A NAME="IDX51"></A>
213 <LI><CODE>LANG</CODE>
215 </OL>
218 Variables whose value is set but is empty are ignored in this lookup.
220 </P>
222 <CODE>LANG</CODE> is the normal environment variable for specifying a locale.
223 As a user, you normally set this variable (unless some of the other variables
224 have already been set by the system, in <TT>&lsquo;/etc/profile&rsquo;</TT> or similar
225 initialization files).
227 </P>
229 <CODE>LC_CTYPE</CODE>, <CODE>LC_NUMERIC</CODE>, <CODE>LC_TIME</CODE>, <CODE>LC_COLLATE</CODE>,
230 <CODE>LC_MONETARY</CODE>, <CODE>LC_MESSAGES</CODE>, and so on, are the environment
231 variables meant to override <CODE>LANG</CODE> and affecting a single locale
232 category only. For example, assume you are a Swedish user in Spain, and you
233 want your programs to handle numbers and dates according to Spanish
234 conventions, and only the messages should be in Swedish. Then you could
235 create a locale named <SAMP>&lsquo;sv_ES&rsquo;</SAMP> or <SAMP>&lsquo;sv_ES.UTF-8&rsquo;</SAMP> by use of the
236 <CODE>localedef</CODE> program. But it is simpler, and achieves the same effect,
237 to set the <CODE>LANG</CODE> variable to <CODE>es_ES.UTF-8</CODE> and the
238 <CODE>LC_MESSAGES</CODE> variable to <CODE>sv_SE.UTF-8</CODE>; these two locales come
239 already preinstalled with the operating system.
241 </P>
243 <CODE>LC_ALL</CODE> is an environment variable that overrides all of these.
244 It is typically used in scripts that run particular programs. For example,
245 <CODE>configure</CODE> scripts generated by GNU autoconf use <CODE>LC_ALL</CODE> to make
246 sure that the configuration tests don't operate in locale dependent ways.
248 </P>
250 Some systems, unfortunately, set <CODE>LC_ALL</CODE> in <TT>&lsquo;/etc/profile&rsquo;</TT> or in
251 similar initialization files. As a user, you therefore have to unset this
252 variable if you want to set <CODE>LANG</CODE> and optionally some of the other
253 <CODE>LC_xxx</CODE> variables.
255 </P>
257 The <CODE>LANGUAGE</CODE> variable is described in the next subsection.
259 </P>
262 <H3><A NAME="SEC13" HREF="gettext_toc.html#TOC13">2.3.3 Specifying a Priority List of Languages</A></H3>
265 Not all programs have translations for all languages. By default, an
266 English message is shown in place of a nonexistent translation. If you
267 understand other languages, you can set up a priority list of languages.
268 This is done through a different environment variable, called
269 <CODE>LANGUAGE</CODE>. GNU <CODE>gettext</CODE> gives preference to <CODE>LANGUAGE</CODE>
270 over <CODE>LC_ALL</CODE> and <CODE>LANG</CODE> for the purpose of message handling,
271 but you still need to have <CODE>LANG</CODE> (or <CODE>LC_ALL</CODE>) set to the primary
272 language; this is required by other parts of the system libraries.
273 For example, some Swedish users who would rather read translations in
274 German than English for when Swedish is not available, set <CODE>LANGUAGE</CODE>
275 to <SAMP>&lsquo;sv:de&rsquo;</SAMP> while leaving <CODE>LANG</CODE> to <SAMP>&lsquo;sv_SE&rsquo;</SAMP>.
277 </P>
279 Special advice for Norwegian users: The language code for Norwegian
280 bokm@ringaccent{a}l changed from <SAMP>&lsquo;no&rsquo;</SAMP> to <SAMP>&lsquo;nb&rsquo;</SAMP> recently (in 2003).
281 During the transition period, while some message catalogs for this language
282 are installed under <SAMP>&lsquo;nb&rsquo;</SAMP> and some older ones under <SAMP>&lsquo;no&rsquo;</SAMP>, it is
283 recommended for Norwegian users to set <CODE>LANGUAGE</CODE> to <SAMP>&lsquo;nb:no&rsquo;</SAMP> so that
284 both newer and older translations are used.
286 </P>
288 In the <CODE>LANGUAGE</CODE> environment variable, but not in the other
289 environment variables, <SAMP>&lsquo;<VAR>ll</VAR>_<VAR>CC</VAR>&rsquo;</SAMP> combinations can be
290 abbreviated as <SAMP>&lsquo;<VAR>ll</VAR>&rsquo;</SAMP> to denote the language's main dialect.
291 For example, <SAMP>&lsquo;de&rsquo;</SAMP> is equivalent to <SAMP>&lsquo;de_DE&rsquo;</SAMP> (German as spoken in
292 Germany), and <SAMP>&lsquo;pt&rsquo;</SAMP> to <SAMP>&lsquo;pt_PT&rsquo;</SAMP> (Portuguese as spoken in Portugal)
293 in this context.
295 </P>
297 Note: The variable <CODE>LANGUAGE</CODE> is ignored if the locale is set to
298 <SAMP>&lsquo;C&rsquo;</SAMP>. In other words, you have to first enable localization, by setting
299 <CODE>LANG</CODE> (or <CODE>LC_ALL</CODE>) to a value other than <SAMP>&lsquo;C&rsquo;</SAMP>, before you can
300 use a language priority list through the <CODE>LANGUAGE</CODE> variable.
302 </P>
305 <H2><A NAME="SEC14" HREF="gettext_toc.html#TOC14">2.4 Installing Translations for Particular Programs</A></H2>
307 <A NAME="IDX52"></A>
308 <A NAME="IDX53"></A>
310 </P>
312 Languages are not equally well supported in all packages using GNU
313 <CODE>gettext</CODE>, and more translations are added over time. Usually, you
314 use the translations that are shipped with the operating system
315 or with particular packages that you install afterwards. But you can also
316 install newer localizations directly. For doing this, you will need an
317 understanding where each localization file is stored on the file system.
319 </P>
321 <A NAME="IDX54"></A>
322 For programs that participate in the Translation Project, you can start
323 looking for translations here:
324 <A HREF="http://translationproject.org/team/index.html">http://translationproject.org/team/index.html</A>.
325 A snapshot of this information is also found in the <TT>&lsquo;ABOUT-NLS&rsquo;</TT> file
326 that is shipped with GNU gettext.
328 </P>
330 For programs that are part of the KDE project, the starting point is:
331 <A HREF="http://i18n.kde.org/">http://i18n.kde.org/</A>.
333 </P>
335 For programs that are part of the GNOME project, the starting point is:
336 <A HREF="http://www.gnome.org/i18n/">http://www.gnome.org/i18n/</A>.
338 </P>
340 For other programs, you may check whether the program's source code package
341 contains some <TT>&lsquo;<VAR>ll</VAR>.po&rsquo;</TT> files; often they are kept together in a
342 directory called <TT>&lsquo;po/&rsquo;</TT>. Each <TT>&lsquo;<VAR>ll</VAR>.po&rsquo;</TT> file contains the
343 message translations for the language whose abbreviation of <VAR>ll</VAR>.
345 </P>
346 <P><HR><P>
347 Go to the <A HREF="gettext_1.html">first</A>, <A HREF="gettext_1.html">previous</A>, <A HREF="gettext_3.html">next</A>, <A HREF="gettext_25.html">last</A> section, <A HREF="gettext_toc.html">table of contents</A>.
348 </BODY>
349 </HTML>