Spaces:
Running
Running
<html> | |
<!-- Created on July, 26 2020 by texi2html 1.78a --> | |
<!-- | |
Written by: Lionel Cons <[email protected]> (original author) | |
Karl Berry <[email protected]> | |
Olaf Bachmann <[email protected]> | |
and many others. | |
Maintained by: Many creative people. | |
Send bugs and suggestions to <[email protected]> | |
--> | |
<head> | |
<title>GNU gettext utilities: 2. The User's View</title> | |
<meta name="description" content="GNU gettext utilities: 2. The User's View"> | |
<meta name="keywords" content="GNU gettext utilities: 2. The User's View"> | |
<meta name="resource-type" content="document"> | |
<meta name="distribution" content="global"> | |
<meta name="Generator" content="texi2html 1.78a"> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | |
<style type="text/css"> | |
<!-- | |
a.summary-letter {text-decoration: none} | |
pre.display {font-family: serif} | |
pre.format {font-family: serif} | |
pre.menu-comment {font-family: serif} | |
pre.menu-preformatted {font-family: serif} | |
pre.smalldisplay {font-family: serif; font-size: smaller} | |
pre.smallexample {font-size: smaller} | |
pre.smallformat {font-family: serif; font-size: smaller} | |
pre.smalllisp {font-size: smaller} | |
span.roman {font-family:serif; font-weight:normal;} | |
span.sansserif {font-family:sans-serif; font-weight:normal;} | |
ul.toc {list-style: none} | |
--> | |
</style> | |
</head> | |
<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000"> | |
<table cellpadding="1" cellspacing="1" border="0"> | |
<tr><td valign="middle" align="left">[<a href="gettext_1.html#SEC1" title="Beginning of this chapter or previous chapter"> << </a>]</td> | |
<td valign="middle" align="left">[<a href="gettext_3.html#SEC16" title="Next chapter"> >> </a>]</td> | |
<td valign="middle" align="left"> </td> | |
<td valign="middle" align="left"> </td> | |
<td valign="middle" align="left"> </td> | |
<td valign="middle" align="left"> </td> | |
<td valign="middle" align="left"> </td> | |
<td valign="middle" align="left">[<a href="gettext_toc.html#SEC_Top" title="Cover (top) of document">Top</a>]</td> | |
<td valign="middle" align="left">[<a href="gettext_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td> | |
<td valign="middle" align="left">[<a href="gettext_21.html#SEC387" title="Index">Index</a>]</td> | |
<td valign="middle" align="left">[<a href="gettext_abt.html#SEC_About" title="About (help)"> ? </a>]</td> | |
</tr></table> | |
<hr size="2"> | |
<a name="Users"></a> | |
<a name="SEC7"></a> | |
<h1 class="chapter"> <a href="gettext_toc.html#TOC7">2. The User's View</a> </h1> | |
<p>Nowadays, when users log into a computer, they usually find that all | |
their programs show messages in their native language – at least for | |
users of languages with an active free software community, like French or | |
German; to a lesser extent for languages with a smaller participation in | |
free software and the GNU project, like Hindi and Filipino. | |
</p> | |
<p>How does this work? How can the user influence the language that is used | |
by the programs? This chapter will answer it. | |
</p> | |
<a name="System-Installation"></a> | |
<a name="SEC8"></a> | |
<h2 class="section"> <a href="gettext_toc.html#TOC8">2.1 Operating System Installation</a> </h2> | |
<p>The default language is often already specified during operating system | |
installation. When the operating system is installed, the installer | |
typically asks for the language used for the installation process and, | |
separately, for the language to use in the installed system. Some OS | |
installers only ask for the language once. | |
</p> | |
<p>This determines the system-wide default language for all users. But the | |
installers often give the possibility to install extra localizations for | |
additional languages. For example, the localizations of KDE (the K | |
Desktop Environment) and OpenOffice.org are often bundled separately, | |
as one installable package per language. | |
</p> | |
<p>At this point it is good to consider the intended use of the machine: If | |
it is a machine designated for personal use, additional localizations are | |
probably not necessary. If, however, the machine is in use in an | |
organization or company that has international relationships, one can | |
consider the needs of guest users. If you have a guest from abroad, for | |
a week, what could be his preferred locales? It may be worth installing | |
these additional localizations ahead of time, since they cost only a bit | |
of disk space at this point. | |
</p> | |
<p>The system-wide default language is the locale configuration that is used | |
when a new user account is created. But the user can have his own locale | |
configuration that is different from the one of the other users of the | |
same machine. He can specify it, typically after the first login, as | |
described in the next section. | |
</p> | |
<a name="Setting-the-GUI-Locale"></a> | |
<a name="SEC9"></a> | |
<h2 class="section"> <a href="gettext_toc.html#TOC9">2.2 Setting the Locale Used by GUI Programs</a> </h2> | |
<p>The immediately available programs in a user's desktop come from a group | |
of programs called a “desktop environment”; it usually includes the window | |
manager, a web browser, a text editor, and more. The most common free | |
desktop environments are KDE, GNOME, and Xfce. | |
</p> | |
<p>The locale used by GUI programs of the desktop environment can be specified | |
in a configuration screen called “control center”, “language settings” | |
or “country settings”. | |
</p> | |
<p>Individual GUI programs that are not part of the desktop environment can | |
have their locale specified either in a settings panel, or through environment | |
variables. | |
</p> | |
<p>For some programs, it is possible to specify the locale through environment | |
variables, possibly even to a different locale than the desktop's locale. | |
This means, instead of starting a program through a menu or from the file | |
system, you can start it from the command-line, after having set some | |
environment variables. The environment variables can be those specified | |
in the next section (<a href="#SEC10">Setting the Locale through Environment Variables</a>); for some versions of | |
KDE, however, the locale is specified through a variable <code>KDE_LANG</code>, | |
rather than <code>LANG</code> or <code>LC_ALL</code>. | |
</p> | |
<a name="Setting-the-POSIX-Locale"></a> | |
<a name="SEC10"></a> | |
<h2 class="section"> <a href="gettext_toc.html#TOC10">2.3 Setting the Locale through Environment Variables</a> </h2> | |
<p>As a user, if your language has been installed for this package, in the | |
simplest case, you only have to set the <code>LANG</code> environment variable | |
to the appropriate ‘<samp><var>ll</var>_<var>CC</var></samp>’ combination. For example, | |
let's suppose that you speak German and live in Germany. At the shell | |
prompt, merely execute | |
‘<samp>setenv LANG de_DE</samp>’ (in <code>csh</code>), | |
‘<samp>export LANG; LANG=de_DE</samp>’ (in <code>sh</code>) or | |
‘<samp>export LANG=de_DE</samp>’ (in <code>bash</code>). This can be done from your | |
‘<tt>.login</tt>’ or ‘<tt>.profile</tt>’ file, once and for all. | |
</p> | |
<a name="Locale-Names"></a> | |
<a name="SEC11"></a> | |
<h3 class="subsection"> <a href="gettext_toc.html#TOC11">2.3.1 Locale Names</a> </h3> | |
<p>A locale name usually has the form ‘<samp><var>ll</var>_<var>CC</var></samp>’. Here | |
‘<samp><var>ll</var></samp>’ is an ISO 639 two-letter language code, and | |
‘<samp><var>CC</var></samp>’ is an ISO 3166 two-letter country code. For example, | |
for German in Germany, <var>ll</var> is <code>de</code>, and <var>CC</var> is <code>DE</code>. | |
You find a list of the language codes in appendix <a href="gettext_18.html#SEC371">Language Codes</a> and | |
a list of the country codes in appendix <a href="gettext_19.html#SEC374">Country Codes</a>. | |
</p> | |
<p>You might think that the country code specification is redundant. But in | |
fact, some languages have dialects in different countries. For example, | |
‘<samp>de_AT</samp>’ is used for Austria, and ‘<samp>pt_BR</samp>’ for Brazil. The country | |
code serves to distinguish the dialects. | |
</p> | |
<p>Many locale names have an extended syntax | |
‘<samp><var>ll</var>_<var>CC</var>.<var>encoding</var></samp>’ that also specifies the character | |
encoding. These are in use because between 2000 and 2005, most users have | |
switched to locales in UTF-8 encoding. For example, the German locale on | |
glibc systems is nowadays ‘<samp>de_DE.UTF-8</samp>’. The older name ‘<samp>de_DE</samp>’ | |
still refers to the German locale as of 2000 that stores characters in | |
ISO-8859-1 encoding – a text encoding that cannot even accommodate the Euro | |
currency sign. | |
</p> | |
<p>Some locale names use ‘<samp><var>ll</var>_<var>CC</var>@<var>variant</var></samp>’ instead of | |
‘<samp><var>ll</var>_<var>CC</var></samp>’. The ‘<samp>@<var>variant</var></samp>’ can denote any kind of | |
characteristics that is not already implied by the language <var>ll</var> and | |
the country <var>CC</var>. It can denote a particular monetary unit. For example, | |
on glibc systems, ‘<samp>de_DE@euro</samp>’ denotes the locale that uses the Euro | |
currency, in contrast to the older locale ‘<samp>de_DE</samp>’ which implies the use | |
of the currency before 2002. It can also denote a dialect of the language, | |
or the script used to write text (for example, ‘<samp>sr_RS@latin</samp>’ uses the | |
Latin script, whereas ‘<samp>sr_RS</samp>’ uses the Cyrillic script to write Serbian), | |
or the orthography rules, or similar. | |
</p> | |
<p>On other systems, some variations of this scheme are used, such as | |
‘<samp><var>ll</var></samp>’. You can get the list of locales supported by your system | |
for your language by running the command ‘<samp>locale -a | grep '^<var>ll</var>'</samp>’. | |
</p> | |
<p>There is also a special locale, called ‘<samp>C</samp>’. | |
When it is used, it disables all localization: in this locale, all programs | |
standardized by POSIX use English messages and an unspecified character | |
encoding (often US-ASCII, but sometimes also ISO-8859-1 or UTF-8, depending on | |
the operating system). | |
</p> | |
<a name="Locale-Environment-Variables"></a> | |
<a name="SEC12"></a> | |
<h3 class="subsection"> <a href="gettext_toc.html#TOC12">2.3.2 Locale Environment Variables</a> </h3> | |
<p>A locale is composed of several <em>locale categories</em>, see <a href="gettext_1.html#SEC4">Aspects in Native Language Support</a>. | |
When a program looks up locale dependent values, it does this according to | |
the following environment variables, in priority order: | |
</p> | |
<ol> | |
<li><a name="IDX33"></a> | |
</li><li> <code>LANGUAGE</code> | |
<a name="IDX34"></a> | |
</li><li> <code>LC_ALL</code> | |
<a name="IDX35"></a> | |
<a name="IDX36"></a> | |
<a name="IDX37"></a> | |
<a name="IDX38"></a> | |
<a name="IDX39"></a> | |
<a name="IDX40"></a> | |
</li><li> <code>LC_xxx</code>, according to selected locale category: | |
<code>LC_CTYPE</code>, <code>LC_NUMERIC</code>, <code>LC_TIME</code>, <code>LC_COLLATE</code>, | |
<code>LC_MONETARY</code>, <code>LC_MESSAGES</code>, ... | |
<a name="IDX41"></a> | |
</li><li> <code>LANG</code> | |
</li></ol> | |
<p>Variables whose value is set but is empty are ignored in this lookup. | |
</p> | |
<p><code>LANG</code> is the normal environment variable for specifying a locale. | |
As a user, you normally set this variable (unless some of the other variables | |
have already been set by the system, in ‘<tt>/etc/profile</tt>’ or similar | |
initialization files). | |
</p> | |
<p><code>LC_CTYPE</code>, <code>LC_NUMERIC</code>, <code>LC_TIME</code>, <code>LC_COLLATE</code>, | |
<code>LC_MONETARY</code>, <code>LC_MESSAGES</code>, and so on, are the environment | |
variables meant to override <code>LANG</code> and affecting a single locale | |
category only. For example, assume you are a Swedish user in Spain, and you | |
want your programs to handle numbers and dates according to Spanish | |
conventions, and only the messages should be in Swedish. Then you could | |
create a locale named ‘<samp>sv_ES</samp>’ or ‘<samp>sv_ES.UTF-8</samp>’ by use of the | |
<code>localedef</code> program. But it is simpler, and achieves the same effect, | |
to set the <code>LANG</code> variable to <code>es_ES.UTF-8</code> and the | |
<code>LC_MESSAGES</code> variable to <code>sv_SE.UTF-8</code>; these two locales come | |
already preinstalled with the operating system. | |
</p> | |
<p><code>LC_ALL</code> is an environment variable that overrides all of these. | |
It is typically used in scripts that run particular programs. For example, | |
<code>configure</code> scripts generated by GNU autoconf use <code>LC_ALL</code> to make | |
sure that the configuration tests don't operate in locale dependent ways. | |
</p> | |
<p>Some systems, unfortunately, set <code>LC_ALL</code> in ‘<tt>/etc/profile</tt>’ or in | |
similar initialization files. As a user, you therefore have to unset this | |
variable if you want to set <code>LANG</code> and optionally some of the other | |
<code>LC_xxx</code> variables. | |
</p> | |
<p>The <code>LANGUAGE</code> variable is described in the next subsection. | |
</p> | |
<a name="The-LANGUAGE-variable"></a> | |
<a name="SEC13"></a> | |
<h3 class="subsection"> <a href="gettext_toc.html#TOC13">2.3.3 Specifying a Priority List of Languages</a> </h3> | |
<p>Not all programs have translations for all languages. By default, an | |
English message is shown in place of a nonexistent translation. If you | |
understand other languages, you can set up a priority list of languages. | |
This is done through a different environment variable, called | |
<code>LANGUAGE</code>. GNU <code>gettext</code> gives preference to <code>LANGUAGE</code> | |
over <code>LC_ALL</code> and <code>LANG</code> for the purpose of message handling, | |
but you still need to have <code>LANG</code> (or <code>LC_ALL</code>) set to the primary | |
language; this is required by other parts of the system libraries. | |
For example, some Swedish users who would rather read translations in | |
German than English for when Swedish is not available, set <code>LANGUAGE</code> | |
to ‘<samp>sv:de</samp>’ while leaving <code>LANG</code> to ‘<samp>sv_SE</samp>’. | |
</p> | |
<p>Special advice for Norwegian users: The language code for Norwegian | |
bokmål changed from ‘<samp>no</samp>’ to ‘<samp>nb</samp>’ recently (in 2003). | |
During the transition period, while some message catalogs for this language | |
are installed under ‘<samp>nb</samp>’ and some older ones under ‘<samp>no</samp>’, it is | |
recommended for Norwegian users to set <code>LANGUAGE</code> to ‘<samp>nb:no</samp>’ so that | |
both newer and older translations are used. | |
</p> | |
<p>In the <code>LANGUAGE</code> environment variable, but not in the other | |
environment variables, ‘<samp><var>ll</var>_<var>CC</var></samp>’ combinations can be | |
abbreviated as ‘<samp><var>ll</var></samp>’ to denote the language's main dialect. | |
For example, ‘<samp>de</samp>’ is equivalent to ‘<samp>de_DE</samp>’ (German as spoken in | |
Germany), and ‘<samp>pt</samp>’ to ‘<samp>pt_PT</samp>’ (Portuguese as spoken in Portugal) | |
in this context. | |
</p> | |
<p>Note: The variable <code>LANGUAGE</code> is ignored if the locale is set to | |
‘<samp>C</samp>’. In other words, you have to first enable localization, by setting | |
<code>LANG</code> (or <code>LC_ALL</code>) to a value other than ‘<samp>C</samp>’, before you can | |
use a language priority list through the <code>LANGUAGE</code> variable. | |
</p> | |
<a name="Working-in-a-Windows-console"></a> | |
<a name="SEC14"></a> | |
<h2 class="section"> <a href="gettext_toc.html#TOC14">2.4 Obtaining good output in a Windows console</a> </h2> | |
<p>On Windows, consoles such as the one started by the <code>cmd.exe</code> | |
program do input and output in an encoding, called “OEM code page”, | |
that is different from the encoding that text-mode programs usually use, | |
called “ANSI code page”. (Note: This problem does not exist for | |
Cygwin consoles; these consoles do input and output in the UTF-8 | |
encoding.) As a workaround, you may request that the programs produce | |
output in this “OEM” encoding. To do so, set the environment variable | |
<code>OUTPUT_CHARSET</code> to the “OEM” encoding, through a command such as | |
</p><table><tr><td> </td><td><pre class="smallexample">set OUTPUT_CHARSET=CP850 | |
</pre></td></tr></table> | |
<p>Note: This has an effect only on strings looked up in message catalogs; | |
other categories of text are usually not affected by this setting. | |
Note also that this environment variable also affects output sent to a | |
file or to a pipe; output to a file is most often expected to be in the | |
“ANSI” or in the UTF-8 encoding. | |
</p> | |
<p>Here are examples of the “ANSI” and “OEM” code pages: | |
</p> | |
<table> | |
<thead><tr><th><p> Territories </p></th><th><p> ANSI encoding </p></th><th><p> OEM encoding | |
</p></th></tr></thead> | |
<tr><td><p> Western Europe </p></td><td><p> CP1252 </p></td><td><p> CP850 | |
</p></td></tr> | |
<tr><td><p> Slavic countries (Latin 2) </p></td><td><p> CP1250 </p></td><td><p> CP852 | |
</p></td></tr> | |
<tr><td><p> Baltic countries </p></td><td><p> CP1257 </p></td><td><p> CP775 | |
</p></td></tr> | |
<tr><td><p> Russia </p></td><td><p> CP1251 </p></td><td><p> CP866 | |
</p></td></tr> | |
</table> | |
<a name="Installing-Localizations"></a> | |
<a name="SEC15"></a> | |
<h2 class="section"> <a href="gettext_toc.html#TOC15">2.5 Installing Translations for Particular Programs</a> </h2> | |
<p>Languages are not equally well supported in all packages using GNU | |
<code>gettext</code>, and more translations are added over time. Usually, you | |
use the translations that are shipped with the operating system | |
or with particular packages that you install afterwards. But you can also | |
install newer localizations directly. For doing this, you will need an | |
understanding where each localization file is stored on the file system. | |
</p> | |
<a name="IDX42"></a> | |
<p>For programs that participate in the Translation Project, you can start | |
looking for translations here: | |
<a href="https://translationproject.org/team/index.html">https://translationproject.org/team/index.html</a>. | |
</p> | |
<p>For programs that are part of the KDE project, the starting point is: | |
<a href="https://l10n.kde.org/">https://l10n.kde.org/</a>. | |
</p> | |
<p>For programs that are part of the GNOME project, the starting point is: | |
<a href="https://wiki.gnome.org/TranslationProject">https://wiki.gnome.org/TranslationProject</a>. | |
</p> | |
<p>For other programs, you may check whether the program's source code package | |
contains some ‘<tt><var>ll</var>.po</tt>’ files; often they are kept together in a | |
directory called ‘<tt>po/</tt>’. Each ‘<tt><var>ll</var>.po</tt>’ file contains the | |
message translations for the language whose abbreviation of <var>ll</var>. | |
</p> | |
<table cellpadding="1" cellspacing="1" border="0"> | |
<tr><td valign="middle" align="left">[<a href="#SEC7" title="Beginning of this chapter or previous chapter"> << </a>]</td> | |
<td valign="middle" align="left">[<a href="gettext_3.html#SEC16" title="Next chapter"> >> </a>]</td> | |
<td valign="middle" align="left"> </td> | |
<td valign="middle" align="left"> </td> | |
<td valign="middle" align="left"> </td> | |
<td valign="middle" align="left"> </td> | |
<td valign="middle" align="left"> </td> | |
<td valign="middle" align="left">[<a href="gettext_toc.html#SEC_Top" title="Cover (top) of document">Top</a>]</td> | |
<td valign="middle" align="left">[<a href="gettext_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td> | |
<td valign="middle" align="left">[<a href="gettext_21.html#SEC387" title="Index">Index</a>]</td> | |
<td valign="middle" align="left">[<a href="gettext_abt.html#SEC_About" title="About (help)"> ? </a>]</td> | |
</tr></table> | |
<p> | |
<font size="-1"> | |
This document was generated by <em>Bruno Haible</em> on <em>July, 26 2020</em> using <a href="https://www.nongnu.org/texi2html/"><em>texi2html 1.78a</em></a>. | |
</font> | |
<br> | |
</p> | |
</body> | |
</html> | |