jpayne@68: jpayne@68: jpayne@68: jpayne@68: jpayne@68:
jpayne@68:[ << ] | jpayne@68:[ >> ] | jpayne@68:jpayne@68: | jpayne@68: | jpayne@68: | jpayne@68: | jpayne@68: | [Top] | jpayne@68:[Contents] | jpayne@68:[Index] | jpayne@68:[ ? ] | jpayne@68:
Nowadays, when users log into a computer, they usually find that all jpayne@68: their programs show messages in their native language – at least for jpayne@68: users of languages with an active free software community, like French or jpayne@68: German; to a lesser extent for languages with a smaller participation in jpayne@68: free software and the GNU project, like Hindi and Filipino. jpayne@68:
jpayne@68:How does this work? How can the user influence the language that is used jpayne@68: by the programs? This chapter will answer it. jpayne@68:
jpayne@68: jpayne@68: jpayne@68: jpayne@68: jpayne@68:The default language is often already specified during operating system jpayne@68: installation. When the operating system is installed, the installer jpayne@68: typically asks for the language used for the installation process and, jpayne@68: separately, for the language to use in the installed system. Some OS jpayne@68: installers only ask for the language once. jpayne@68:
jpayne@68:This determines the system-wide default language for all users. But the jpayne@68: installers often give the possibility to install extra localizations for jpayne@68: additional languages. For example, the localizations of KDE (the K jpayne@68: Desktop Environment) and LibreOffice are often bundled separately, as one jpayne@68: installable package per language. jpayne@68:
jpayne@68:At this point it is good to consider the intended use of the machine: If jpayne@68: it is a machine designated for personal use, additional localizations are jpayne@68: probably not necessary. If, however, the machine is in use in an jpayne@68: organization or company that has international relationships, one can jpayne@68: consider the needs of guest users. If you have a guest from abroad, for jpayne@68: a week, what could be his preferred locales? It may be worth installing jpayne@68: these additional localizations ahead of time, since they cost only a bit jpayne@68: of disk space at this point. jpayne@68:
jpayne@68:The system-wide default language is the locale configuration that is used jpayne@68: when a new user account is created. But the user can have his own locale jpayne@68: configuration that is different from the one of the other users of the jpayne@68: same machine. He can specify it, typically after the first login, as jpayne@68: described in the next section. jpayne@68:
jpayne@68: jpayne@68: jpayne@68: jpayne@68:The immediately available programs in a user's desktop come from a group jpayne@68: of programs called a “desktop environment”; it usually includes the window jpayne@68: manager, a web browser, a text editor, and more. The most common free jpayne@68: desktop environments are KDE, GNOME, and Xfce. jpayne@68:
jpayne@68:The locale used by GUI programs of the desktop environment can be specified jpayne@68: in a configuration screen called “control center”, “language settings” jpayne@68: or “country settings”. jpayne@68:
jpayne@68:Individual GUI programs that are not part of the desktop environment can jpayne@68: have their locale specified either in a settings panel, or through environment jpayne@68: variables. jpayne@68:
jpayne@68:For some programs, it is possible to specify the locale through environment
jpayne@68: variables, possibly even to a different locale than the desktop's locale.
jpayne@68: This means, instead of starting a program through a menu or from the file
jpayne@68: system, you can start it from the command-line, after having set some
jpayne@68: environment variables. The environment variables can be those specified
jpayne@68: in the next section (Setting the Locale through Environment Variables); for some versions of
jpayne@68: KDE, however, the locale is specified through a variable KDE_LANG
,
jpayne@68: rather than LANG
or LC_ALL
.
jpayne@68:
As a user, if your language has been installed for this package, in the
jpayne@68: simplest case, you only have to set the LANG
environment variable
jpayne@68: to the appropriate ‘ll_CC’ combination. For example,
jpayne@68: let's suppose that you speak German and live in Germany. At the shell
jpayne@68: prompt, merely execute
jpayne@68: ‘setenv LANG de_DE’ (in csh
),
jpayne@68: ‘export LANG; LANG=de_DE’ (in sh
) or
jpayne@68: ‘export LANG=de_DE’ (in bash
). This can be done from your
jpayne@68: ‘.login’ or ‘.profile’ file, once and for all.
jpayne@68:
A locale name usually has the form ‘ll_CC’. Here
jpayne@68: ‘ll’ is an ISO 639 two-letter language code, and
jpayne@68: ‘CC’ is an ISO 3166 two-letter country code. For example,
jpayne@68: for German in Germany, ll is de
, and CC is DE
.
jpayne@68: You find a list of the language codes in appendix Language Codes and
jpayne@68: a list of the country codes in appendix Country Codes.
jpayne@68:
You might think that the country code specification is redundant. But in jpayne@68: fact, some languages have dialects in different countries. For example, jpayne@68: ‘de_AT’ is used for Austria, and ‘pt_BR’ for Brazil. The country jpayne@68: code serves to distinguish the dialects. jpayne@68:
jpayne@68:Many locale names have an extended syntax jpayne@68: ‘ll_CC.encoding’ that also specifies the character jpayne@68: encoding. These are in use because between 2000 and 2005, most users have jpayne@68: switched to locales in UTF-8 encoding. For example, the German locale on jpayne@68: glibc systems is nowadays ‘de_DE.UTF-8’. The older name ‘de_DE’ jpayne@68: still refers to the German locale as of 2000 that stores characters in jpayne@68: ISO-8859-1 encoding – a text encoding that cannot even accommodate the Euro jpayne@68: currency sign. jpayne@68:
jpayne@68:Some locale names use ‘ll_CC@variant’ instead of jpayne@68: ‘ll_CC’. The ‘@variant’ can denote any kind of jpayne@68: characteristics that is not already implied by the language ll and jpayne@68: the country CC. It can denote a particular monetary unit. For example, jpayne@68: on glibc systems, ‘de_DE@euro’ denotes the locale that uses the Euro jpayne@68: currency, in contrast to the older locale ‘de_DE’ which implies the use jpayne@68: of the currency before 2002. It can also denote a dialect of the language, jpayne@68: or the script used to write text (for example, ‘sr_RS@latin’ uses the jpayne@68: Latin script, whereas ‘sr_RS’ uses the Cyrillic script to write Serbian), jpayne@68: or the orthography rules, or similar. jpayne@68:
jpayne@68:On other systems, some variations of this scheme are used, such as jpayne@68: ‘ll’. You can get the list of locales supported by your system jpayne@68: for your language by running the command ‘locale -a | grep '^ll'’. jpayne@68:
jpayne@68:There is also a special locale, called ‘C’. jpayne@68: When it is used, it disables all localization: in this locale, all programs jpayne@68: standardized by POSIX use English messages and an unspecified character jpayne@68: encoding (often US-ASCII, but sometimes also ISO-8859-1 or UTF-8, depending on jpayne@68: the operating system). jpayne@68:
jpayne@68: jpayne@68: jpayne@68: jpayne@68:A locale is composed of several locale categories, see Aspects in Native Language Support. jpayne@68: When a program looks up locale dependent values, it does this according to jpayne@68: the following environment variables, in priority order: jpayne@68:
jpayne@68:LANGUAGE
jpayne@68:
jpayne@68: LC_ALL
jpayne@68:
jpayne@68:
jpayne@68:
jpayne@68:
jpayne@68:
jpayne@68:
jpayne@68: LC_xxx
, according to selected locale category:
jpayne@68: LC_CTYPE
, LC_NUMERIC
, LC_TIME
, LC_COLLATE
,
jpayne@68: LC_MONETARY
, LC_MESSAGES
, ...
jpayne@68:
jpayne@68: LANG
jpayne@68: Variables whose value is set but is empty are ignored in this lookup. jpayne@68:
jpayne@68:LANG
is the normal environment variable for specifying a locale.
jpayne@68: As a user, you normally set this variable (unless some of the other variables
jpayne@68: have already been set by the system, in ‘/etc/profile’ or similar
jpayne@68: initialization files).
jpayne@68:
LC_CTYPE
, LC_NUMERIC
, LC_TIME
, LC_COLLATE
,
jpayne@68: LC_MONETARY
, LC_MESSAGES
, and so on, are the environment
jpayne@68: variables meant to override LANG
and affecting a single locale
jpayne@68: category only. For example, assume you are a Swedish user in Spain, and you
jpayne@68: want your programs to handle numbers and dates according to Spanish
jpayne@68: conventions, and only the messages should be in Swedish. Then you could
jpayne@68: create a locale named ‘sv_ES’ or ‘sv_ES.UTF-8’ by use of the
jpayne@68: localedef
program. But it is simpler, and achieves the same effect,
jpayne@68: to set the LANG
variable to es_ES.UTF-8
and the
jpayne@68: LC_MESSAGES
variable to sv_SE.UTF-8
; these two locales come
jpayne@68: already preinstalled with the operating system.
jpayne@68:
LC_ALL
is an environment variable that overrides all of these.
jpayne@68: It is typically used in scripts that run particular programs. For example,
jpayne@68: configure
scripts generated by GNU autoconf use LC_ALL
to make
jpayne@68: sure that the configuration tests don't operate in locale dependent ways.
jpayne@68:
Some systems, unfortunately, set LC_ALL
in ‘/etc/profile’ or in
jpayne@68: similar initialization files. As a user, you therefore have to unset this
jpayne@68: variable if you want to set LANG
and optionally some of the other
jpayne@68: LC_xxx
variables.
jpayne@68:
The LANGUAGE
variable is described in the next subsection.
jpayne@68:
Not all programs have translations for all languages. By default, an
jpayne@68: English message is shown in place of a nonexistent translation. If you
jpayne@68: understand other languages, you can set up a priority list of languages.
jpayne@68: This is done through a different environment variable, called
jpayne@68: LANGUAGE
. GNU gettext
gives preference to LANGUAGE
jpayne@68: over LC_ALL
and LANG
for the purpose of message handling,
jpayne@68: but you still need to have LANG
(or LC_ALL
) set to the primary
jpayne@68: language; this is required by other parts of the system libraries.
jpayne@68: For example, some Swedish users who would rather read translations in
jpayne@68: German than English for when Swedish is not available, set LANGUAGE
jpayne@68: to ‘sv:de’ while leaving LANG
to ‘sv_SE’.
jpayne@68:
Special advice for Norwegian users: The language code for Norwegian
jpayne@68: bokmål changed from ‘no’ to ‘nb’ recently (in 2003).
jpayne@68: During the transition period, while some message catalogs for this language
jpayne@68: are installed under ‘nb’ and some older ones under ‘no’, it is
jpayne@68: recommended for Norwegian users to set LANGUAGE
to ‘nb:no’ so that
jpayne@68: both newer and older translations are used.
jpayne@68:
In the LANGUAGE
environment variable, but not in the other
jpayne@68: environment variables, ‘ll_CC’ combinations can be
jpayne@68: abbreviated as ‘ll’ to denote the language's main dialect.
jpayne@68: For example, ‘de’ is equivalent to ‘de_DE’ (German as spoken in
jpayne@68: Germany), and ‘pt’ to ‘pt_PT’ (Portuguese as spoken in Portugal)
jpayne@68: in this context.
jpayne@68:
Note: The variable LANGUAGE
is ignored if the locale is set to
jpayne@68: ‘C’. In other words, you have to first enable localization, by setting
jpayne@68: LANG
(or LC_ALL
) to a value other than ‘C’, before you can
jpayne@68: use a language priority list through the LANGUAGE
variable.
jpayne@68:
On Windows, consoles such as the one started by the cmd.exe
jpayne@68: program do input and output in an encoding, called “OEM code page”,
jpayne@68: that is different from the encoding that text-mode programs usually use,
jpayne@68: called “ANSI code page”. (Note: This problem does not exist for
jpayne@68: Cygwin consoles; these consoles do input and output in the UTF-8
jpayne@68: encoding.) As a workaround, you may request that the programs produce
jpayne@68: output in this “OEM” encoding. To do so, set the environment variable
jpayne@68: OUTPUT_CHARSET
to the “OEM” encoding, through a command such as
jpayne@68:
set OUTPUT_CHARSET=CP850 jpayne@68: |
Note: This has an effect only on strings looked up in message catalogs; jpayne@68: other categories of text are usually not affected by this setting. jpayne@68: Note also that this environment variable also affects output sent to a jpayne@68: file or to a pipe; output to a file is most often expected to be in the jpayne@68: “ANSI” or in the UTF-8 encoding. jpayne@68:
jpayne@68:Here are examples of the “ANSI” and “OEM” code pages: jpayne@68:
jpayne@68:Territories | ANSI encoding | OEM encoding jpayne@68: |
---|---|---|
Western Europe | CP1252 | CP850 jpayne@68: |
Slavic countries (Latin 2) | CP1250 | CP852 jpayne@68: |
Baltic countries | CP1257 | CP775 jpayne@68: |
Russia | CP1251 | CP866 jpayne@68: |
Languages are not equally well supported in all packages using GNU
jpayne@68: gettext
, and more translations are added over time. Usually, you
jpayne@68: use the translations that are shipped with the operating system
jpayne@68: or with particular packages that you install afterwards. But you can also
jpayne@68: install newer localizations directly. For doing this, you will need an
jpayne@68: understanding where each localization file is stored on the file system.
jpayne@68:
For programs that participate in the Translation Project, you can start jpayne@68: looking for translations here: jpayne@68: https://translationproject.org/team/index.html. jpayne@68:
jpayne@68:For programs that are part of the KDE project, the starting point is: jpayne@68: https://l10n.kde.org/. jpayne@68:
jpayne@68:For programs that are part of the GNOME project, the starting point is: jpayne@68: https://wiki.gnome.org/TranslationProject. jpayne@68:
jpayne@68:For other programs, you may check whether the program's source code package jpayne@68: contains some ‘ll.po’ files; often they are kept together in a jpayne@68: directory called ‘po/’. Each ‘ll.po’ file contains the jpayne@68: message translations for the language whose abbreviation of ll. jpayne@68:
jpayne@68: jpayne@68:[ << ] | jpayne@68:[ >> ] | jpayne@68:jpayne@68: | jpayne@68: | jpayne@68: | jpayne@68: | jpayne@68: | [Top] | jpayne@68:[Contents] | jpayne@68:[Index] | jpayne@68:[ ? ] | jpayne@68:
jpayne@68:
jpayne@68: This document was generated by Bruno Haible on February, 21 2024 using texi2html 1.78a.
jpayne@68:
jpayne@68:
jpayne@68:
jpayne@68: