Localization/Guide/zh-cn

时区
为了在现在的位置保持正确的系统时间，必须设置时区. 在 系统时间 这篇文章中可以找到有关基于 OpenRC 系统 和 基于 systemd 的系统 的说明.

什么是 locale?
区域设置 (locale) 是大多数程序用来确定国家和语言特定设置的一组信息. locale 及其数据是系统库的一部分，大多数系统上可以在 找到 locale. 一个 locale 名称通常被命名为 ，  是两个（或三个）单词的语言代码（在 ISO-639 中指定），   是两个字母的国家代码（在 ISO-3166 中指定）. 像  和   这样的变量通常被附加到 locale  名称之后，例如   or. 请浏览 维基百科 了解更多关于 locale 信息和相关文章.

locale 的环境变量
下表给出了 locale 设置中控制不同方面的变量. 他们都采用上面给出的  格式 locale 的一个名称.

通常，用户只在全局设置 LANG 变量.

生成特定 locales
大多数用户可能只会在其系统上使用一个或两个locale. 在 文件中说明了如何指定其他 locale.

下一步是运行. 它将生成所有在 文件中指定的 locale 并且把他们写入到 locale-存档（）.

用验证所选择的 locale 是否可用.

可以用 列出  文件.

可以用 命令显示原始数据.

OpenRC
使用 OpenRC 时，locale 设置存储在环境变量中. 通常在 （系统级的设置）和   (用于用户特定的设置). 更多细节可以在 UTF-8 文章中找到. 系统级的设置可以通过 eselect locale 进行管理. 例如，要将 LANG 变量的值设置为 ：

当然，也可以手动编辑文件使 locale 变量多样化.

In some cases users may notice glitchy non-English representation in some applications like Krusader (https://bugs.kde.org/show_bug.cgi?id=371582). Removing or commenting the  line from  should fix the problem.

It's also possible, and pretty common especially in a more traditional UNIX environment, to leave the global settings unchanged, i.e. in the  locale. Users can still specify their preferred locale in their own shell configuration file:

配置系统的另一种方法是将其保留在默认的  locale，但同时启用UTF-8 字符表示（character representation）. 此选项使用 中的以下设置实现：

使用上面的代码片段，用户将能够正确地查看本地化文件名，而不必完全使用所选的语言.

一旦设置了正确的 locale，请确保更新环境变量以使系统知道更改了 locale.

对于系统级默认 locale：

For a user-specific locale:

After this, kill the X server by pressing ++, log out, then log in as a user.

Now, verify that the changes have taken effect:

systemd
With systemd set the locale with the command. Check the list of available locales with:

Then set the desired locale:

Finally check if the result is good:

OpenRC
The keyboard layout used by the console is set in by the keymap variable. Valid values can be found in. has further subdivisions into layout (,, etc.). Some languages have multiple options - experiment with the various options to decide which one fits your needs best.

systemd
With systemd the keymap layout used for the console can be set using the command. First check the available keymap layouts:

Then set the requested console keymap layout:

Finally check if the console keymap layout was set correctly:

OpenRC
The keyboard layout to be used by the X server is specified in by the XkbLayout option. For details visit the Xorg guide and the article about Keyboard layout switching.

systemd
With systemd the keymap layout for the X11 server can be set using the command. First check the available X11 keymap layouts:

Then set the requested X11 keymap layout:

Finally check if the X11 keymap layout was set correctly:

本地语言支持
For message based localization to work in programs that support it and have the  USE flag, compile the programs with this flag set. Message strings are installed in files. Most of the programs using the Native Language Support (NLS) also need the gettext library to extract and use localized messages. Of course, Portage will automatically install it when needed.

After enabling the  USE flag some packages might need to be re-emerged:

LINGUAS
There is also an additional LINGUAS variable that is used by some gettext-based build systems to control which localization files are built and installed. The variable takes in space-separated list of language codes, and a suggested place to set it is :

Note that there is a large difference between LINGUAS being unset and being set to an empty value: with, most ebuilds would install only the packages' default language but none of the   files.

L10N
A USE_EXPAND variable called L10N decides which extra localization support will be installed. This is commonly used for downloads of additional language packs by packages. Similar to LINGUAS, the variable takes a space separated list of language tags, and it can be set in :

To set it per-package, edit and prefix the requested language packs with "l10n_", as shown in the next example:

Note that while the common two letter language codes (like  or  ) are identical in LINGUAS and L10N, more complex entries have a different syntax because L10N uses IETF language tags (aka BCP 47). For example,  and   in LINGUAS become   and   in L10N, respectively.

可用的 L10N 值列表在 中提供：

After setting the L10N USE_EXPAND variable it may be necessary to re-emerge some packages:

另请参阅

 * 配置 locales (Gentoo 手册)
 * 键盘布局 inside the Evdev article
 * X resources

外部资源

 * Locales and Internationalization (gnu.org)
 * L10N USE_EXPAND variable replacing LINGUAS
 * Michał Górny: How LINGUAS are thrice wrong!
 * [gentoo-dev [RFC] How to deal with LINGUAS mess? ]
 * [gentoo-dev [RFC] Masterplan for solving LINGUAS problems ]