Próximo: Serviços, Anterior: Disposição do teclado, Acima: Configuração do sistema [Conteúdo][Índice]
A locale defines cultural conventions for a particular language and
region of the world (veja Locales em The GNU C Library Reference
Manual). Each locale has a name that typically has the form
language_territory.codeset
—e.g.,
fr_LU.utf8
designates the locale for the French language, with
cultural conventions from Luxembourg, and using the UTF-8 encoding.
Usually, you will want to specify the default locale for the machine using
the locale
field of the operating-system
declaration
(veja locale
).
The selected locale is automatically added to the locale definitions
known to the system if needed, with its codeset inferred from its
name—e.g., bo_CN.utf8
will be assumed to use the UTF-8
codeset. Additional locale definitions can be specified in the
locale-definitions
slot of operating-system
—this is useful,
for instance, if the codeset could not be inferred from the locale name.
The default set of locale definitions includes some widely used locales, but
not all the available locales, in order to save space.
For instance, to add the North Frisian locale for Germany, the value of that field may be:
(cons (locale-definition
(name "fy_DE.utf8") (source "fy_DE"))
%default-locale-definitions)
Likewise, to save space, one might want locale-definitions
to list
only the locales that are actually used, as in:
(list (locale-definition
(name "ja_JP.eucjp") (source "ja_JP")
(charset "EUC-JP")))
The compiled locale definitions are available at
/run/current-system/locale/X.Y, where X.Y
is the libc version,
which is the default location where the GNU libc provided by Guix looks
for locale data. This can be overridden using the LOCPATH
environment
variable (veja LOCPATH
and locale packages).
The locale-definition
form is provided by the (gnu system
locale)
module. Details are given below.
This is the data type of a locale definition.
name
The name of the locale. Veja Locale Names em The GNU C Library Reference Manual, for more information on locale names.
source
The name of the source for that locale. This is typically the
language_territory
part of the locale name.
charset
(default: "UTF-8"
)The “character set” or “code set” for that locale, as defined by IANA.
A list of commonly used UTF-8 locales, used as the default value of the
locale-definitions
field of operating-system
declarations.
These locale definitions use the normalized codeset for the part that
follows the dot in the name (veja normalized
codeset em The GNU C Library Reference Manual). So for instance it
has uk_UA.utf8
but not, say, uk_UA.UTF-8
.
operating-system
declarations provide a locale-libcs
field to
specify the GNU libc packages that are used to compile locale
declarations (veja operating-system
Reference). “Why would I care?”,
you may ask. Well, it turns out that the binary format of locale data is
occasionally incompatible from one libc version to another.
For instance, a program linked against libc version 2.21 is unable to read
locale data produced with libc 2.22; worse, that program aborts
instead of simply ignoring the incompatible locale data32. Similarly, a program linked
against libc 2.22 can read most, but not all, of the locale data from libc
2.21 (specifically, LC_COLLATE
data is incompatible); thus calls to
setlocale
may fail, but programs will not abort.
The “problem” with Guix is that users have a lot of freedom: They can choose whether and when to upgrade software in their profiles, and might be using a libc version different from the one the system administrator used to build the system-wide locale data.
Fortunately, unprivileged users can also install their own locale data and
define GUIX_LOCPATH
accordingly (veja GUIX_LOCPATH
and locale packages).
Still, it is best if the system-wide locale data at
/run/current-system/locale is built for all the libc versions
actually in use on the system, so that all the programs can access it—this
is especially crucial on a multi-user system. To do that, the administrator
can specify several libc packages in the locale-libcs
field of
operating-system
:
(use-package-modules base) (operating-system ;; … (locale-libcs (list glibc-2.21 (canonical-package glibc))))
This example would lead to a system containing locale definitions for both libc 2.21 and the current version of libc in /run/current-system/locale.
Versions 2.23 and later of GNU libc will simply skip the incompatible locale data, which is already an improvement.
Próximo: Serviços, Anterior: Disposição do teclado, Acima: Configuração do sistema [Conteúdo][Índice]