区域 设置
此條 |
此條 |
实际落实
编辑计算
locale
- LANGUAGE
指定 个人对语言 环境值的主 次 偏 好 ,例 如zh_CN:en_US:en - LC_ALL 这不
是 一个环境变量,是 一 个可被 C语言库函数 setlocale设置的 宏 ,其值可 覆 盖所有 其他的 locale设定。因 此缺省 时此值为空 - LC_xxx
可 设定locale各 方面 (category)的 值,可 以覆盖LANG的 值。 - LANG
指定 默 认使用 的 locale值
language[_territory[.codeset]][@modifier]
其中language
bash
$ LC_TIME=en_US.UTF-8 date Fri Oct 31 19:51:16 CST 2014 $ LC_TIME=fi_FI.UTF-8 date pe 31.10.2014 19.52.00 +0800 $ LC_TIME=zh_CN.UTF-8 date 2014年 10月 31日 星 期 五 19:53:07 CST
在 文 件 /usr/share/i18n/SUPPORTED中 ,列 出 了 当 前 系 统支持 的 所有 locale与 字 符 集 的 名字 。在 目 录/var/lib/locales/supported.d/下 ,列 出 了 当 前 系 统已经生成 的 所有 locale的 名字 。在 文 件 /var/lib/locales/supported.d/local中 ,列 出 了 所有 想 要 生成 或 已 经生成 的 locale的 名字 在 目 录/usr/lib/locale/<locale_name>/LC_*,用 locale-gen编译出 的 locale文 件 在 文 件 /usr/lib/locale/locale-archive中 ,包含 了 很多本地 已 经生成 的 locale的 具体 内容 ,因 此这个文件 往往 很大。使用 命令 localedef管理 这一 文 件 。使用 locale-gen命令 编译出来 的 locale内容 默 认写入 该文件 中 。在 文 件 /etc/default/locale中 ,可 以手动配置 locale环境变量,LC_CTYPE之 类在 目 录/usr/share/i18n/charmaps下 ,缺 省 的 charmap存 放 路 径 在 目 录/usr/share/i18n/locales下 ,缺 省 的 locale source file存 放 路 径
- locale
列 出 当 前 采 用 的 各 项本地 策略 ,这些由 LC_*环境变量定 义 - locale charmap
列 出 系 统当前 使用 的 字 符 集 - locale -a
列 出 系 统中已 经安装 的 所有 locale - locale -m
列 出 系 统中已 经安装 的 所有 charmap - locale-gen --purge
将 /usr/lib/locale/里 面 的 locale支持 文 件 删掉 - 编辑
文 件 /var/lib/locales/supported.d/local,增加 需要 的 locale与 字 符 集 名字 ,如:
en_US.UTF-8 UTF-8 cs_CZ.UTF-8 UTF-8 cs_CZ.iso88592 iso88592 zh_CN.UTF-8 UTF-8 zh_CN.GBK GBK zh_CN.GB2312 GB2312 zh_CN.GB18030 GB18030
或 者 使用 命令 sudo locale-gen en_US.UTF-8,生成 制定 的 locale en_US.UTF-8,并把这个locale名字 加入 文 件 /var/lib/locales/supported.d/local中 或 者 使用 命令 sudo locale-gen,生成 所有 列 在 文 件 /var/lib/locales/supported.d/local中 的 locale或 者
cd /usr/share/locales sudo ./install-language-pack zh_CN
也可以安
或 者 使用 命令 localedef -f UTF-8 -i zh_CN zh_CN.UTF8,从字符 映 射 文 件 UTF-8,locale源 文 件 zh_CN,编译出 locale称 为zh_CN.UTF8,存 放 入 文 件 /usr/lib/locale/locale-archive中 使用 命令 localedef --list-archive,列 出 文 件 /usr/lib/locale/locale-archive中 所有 可用 的 locale的 名字 - sudo apt-get install language-selector language-env language-pack-zh-hans language-pack-zh-hant
安 装 中 文 语言包 - sudo nano /etc/default/locale
修 改 该文件 内容 。
Windows SDK规定,“语言”
+-------------+---------+-------------------------+-------------------------+ | Reserved | Sort ID | SubLanguage ID | Primary Language ID | +-------------+---------+-------------------------+-------------------------+ 31 20 19 16 15 10 9 0 bit
LCID
locale :: primaryLanguage[-Script][-SubLanguage[_sortorder]] | "locale-name" | "language[_countryORregion[.CodePage]]" | ".CodePage" | "C" | "" | NULL
- primaryLanguage
是 ISO 639-1或 ISO 639-2/T中 定 义的语言缩写的 小 写 形式 ; - Script
是 ISO 15924定 义的书写系 统的首 字母 大 写 的 4字母 表示 。例 如,拉 丁字 母 拼写的 乌兹别克语为“uz-Latn-UZ”。 - SubLanguage
是 ISO 3166-1中 定 义的国家 /地区 二位字母代码的大写形式;例 如:zh-CN_stroke的 值为MAKELCID(MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED), SORT_CHINESE_PRC),即 133124。 - locale-name
形式 是 简短的 标准化 字 符 串 ,见表 的 Language tag栏目(页面存 档备份,存 于互联网档案 馆)。a short, IETF-standardized string; for example, en-US for English (United States) or bs-Cyrl-BA for Bosnian (Cyrillic, Bosnia and Herzegovina). These forms are preferred. For a list of supported locale names by Windows operating system version, see the Language tag column of the table in Appendix A: Product Behavior in [MS-LCID]: Windows Language Code Identifier (LCID) Reference. This resource lists the supported language, script, and region parts of the locale names. For information about the supported locale names that have non-default sort orders, see the Locale name column in Sort Order Identifiers. Under Windows 10 or later, locale names that correspond to valid BCP-47 language tags are allowed. For example, jp-US is a valid BCP-47 tag, but it is effectively only US for locale functionality. 同 一个区域设置(locale),可 以有多 种字 符 集 编码表示 。例 如,Windows操作 系 统的简体中 文 的 默 认编码字符 集 (即 代 码页)是 GBK,即 “936 (ANSI/OEM - Simplified Chinese GBK)”。而Linux操作 系 统统一 使用 UTF8字 符 集 ,所以 Linux简体中 文 的 默 认编码字符 集 是 UTF8。所有 代 码页列 表 见:Code Page Identifiers(页面存 档备份,存 于互联网档案 馆)。如果需要 指出 使用 的 代 码页,在 上述 字 符 串 最 后 用 “.”区 隔 ,后 跟Windows代 码页数字 或 者 “ACP”、“OCP”。例 如:"French_Canada.1252"。指定 代 码页只 适用于 LC_ALL或 LC_CTYPE。可 以对当 前 默 认的locale只 指 明代 码页,形 如".code_page"。使用 用 户缺省 语言与国 家 地区 设置,即 来 自 GetUserDefaultLocaleName()的 结果。不 建 议采用 此种方式 ,因 为可能会 产生不一致 结果。
对于C标准库函
Locale Name | language[_country_region[.code_page]]
- GetUserDefaultLCID 获取
当 前 用 户的缺 省 LCID。对于简体中 文 操作 系 统返回 值为2052 - GetUserDefaultLocaleName 获取
当 前 用 户的缺 省 locale的 名字 。对于简体中 文 操作 系 统该名字 为zh-CN - GetSystemDefaultLCID 获取
系 统的缺 省 LCID。对于简体中 文 操作 系 统返回 值为2052 - GetSystemDefaultLocaleName 获取
系 统缺省 locale的 名字 - GetThreadLocale() 获取
当 前 线程的 LCID - SetThreadLocale 设置
当 前 线程的 LCID。 - IsValidLocaleName
判断 一个字符串是否为当前操作系统支持的locale的 名字 - LocaleNameToLCID 从locale
的 名字 获取它的LCID - GetLocaleInfoEx 获取
指定 locale的 各 方面 的 信 息 - EnumSystemLocalesEx
枚 举当前 操作 系 统支持 的 所有 的 locale的 名字 - EnumCalendarInfoExEx
枚 举指定 locale的 日 历数据 。例 如zh-TW有 两个日 历型,分 别为“格 里 历(本地 )”与 “格 里 历(英文 )”。 - EnumDateInfoExEx
枚 举指定 locale的 各 种calendar的 日 期 格式 。 - GetCalendarInfoEx 查询
指定 locale指定 日 历型的 指定 方面 的 数 据 。 - GetDateFormatEx
把 时间数 据 转换为指定 格式 的 日 期 字 符 串 。 - GetTimeFormatEx
把 时间数 据 转换为指定 格式 的 时间字 符 串 。 - GetDurationFormatEx
把 一段持续时间的数据转换为指定格式的字符串。 - EnumSystemLanguageGroups
同 一语言组可能共享键盘布局、输入法 、TT字体 、代 码页翻 译表等 等 。 - GetSystemDefaultLangID
系 统缺省 的 非 Unicode语言 - GetKeyboardLayout
当 前 进程的 输入法 - GetSystemDefaultUILanguage
菜 单、对话框 、Windows消息 、INF文 件 、帮助文 件 等 的 默 认语言 - GetSystemPreferredUILanguages
操作 系 统使用 的 菜 单、对话框 、Windows消息 、INF文 件 、帮助文 件 等 的 语言 - GetUserDefaultUILanguage
用 户使用 的 菜 单、对话框 、Windows消息 、帮助文 件 等 的 语言 - GetUserPreferredUILanguages
用 户使用 的 菜 单、对话框 、Windows消息 、帮助文 件 等 的 语言集合 - GetThreadPreferredUILanguages
当 前 线程使用 的 UI语言集合
列 表
编辑
简写 | |||
---|---|---|---|
af | 0x0436 | 1078 | |
af-ZA | |||
am | |||
am-ET | |||
sq | 0x041C | 1052 | |
ar | |||
ar-AE | 0x3801 | 14337 | |
ar-BH | 0x3C01 | 15361 | |
ar-DZ | 0x1401 | 5121 | |
ar-EG | 0x0C01 | 3073 | |
ar-IQ | 0x0801 | 2049 | |
ar-JO | 0x2C01 | 11265 | |
ar-KW | 0x3401 | 13313 | |
ar-LB | 0x3001 | 12289 | |
ar-LY | 0x1001 | 4097 | |
ar-MA | 0x1801 | 6145 | |
arn | |||
arn-CL | |||
ar-OM | 0x2001 | 8193 | |
ar-QA | 0x4001 | 16385 | |
ar-SA | 0x0401 | 1025 | |
ar-SY | 0x2801 | 10241 | |
ar-TN | 0x1C01 | 7169 | |
ar-YE | 0x2401 | 9217 | |
as | |||
as-IN | |||
亚美 |
hy | 0x042B | 1067 |
az | |||
az-Latn | 0x042C | 1068 | |
az-Cyrl | 0x082C | 2092 | |
az-Latn-AZ | 0x042C | 1068 | |
az-Cyrl-AZ | 0x082C | 2092 | |
ba | |||
ba-RU | |||
eu | 0x042D | 1069 | |
be | 0x0423 | 1059 | |
be-BY | |||
bg | 0x0402 | 1026 | |
bg-BG | |||
bn | |||
bg-BD | |||
bg-IN | |||
bo | |||
bo-CN | |||
bo | |||
br-FR | |||
bs | |||
bs-Cyrl | |||
bs-Cyrl-BA | |||
bs-Latn | |||
bs-Latn-BA | |||
ca | 0x0403 | 1027 | |
ca-ES | 0x0403 | 1027 | |
zh | |||
zh-CN | 0x0804 | 2052 | |
zh-CN_stroke | 0x20804 | ||
zh-Hans | 0x0004 | ||
zh-Hant | 0x7C04 | ||
zh-HK | 0x0C04 | 3076 | |
zh-HK_radstr | 0x0C04 | 3076 | |
zh-MO | 0x1404 | 5124 | |
zh-MO_radstr | 0x1404 | 5124 | |
zh-MO_stroke | 0x1404 | 5124 | |
zh-SG | 0x1004 | 4100 | |
zh-SG_stroke | 0x1004 | 4100 | |
zh-TW | 0x0404 | 1028 | |
zh-TW | 0x30404 | ||
zh-TW_pronun | 0x0404 | 1028 | |
zh-TW_radstr | 0x0404 | 1028 | |
hr | 0x041A | 1050 | |
co | |||
co-FR | |||
cs | 0x0405 | 1029 | |
cs-CZ | |||
cy | |||
cy-GB | |||
da | 0x0406 | 1030 | |
da-DK | 1030 | ||
nl-nl | 0x0413 | 1043 | |
nl-be | 0x0813 | 2067 | |
en-029 | |||
en- |
0x0C09 | 3081 | |
en-BZ | 0x2809 | 10249 | |
en-CA | 0x1009 | 4105 | |
en-CB | 0x2409 | 9225 | |
en-IN | 0x4009 | 16393 | |
en-IE | 0x1809 | 6153 | |
en-JM | 0x2009 | 8201 | |
en-MY | 0x4409 | 17417 | |
en-NZ | 0x1409 | 5129 | |
en-PH | 0x3409 | 13321 | |
en-SG | 0x4809 | 18441 | |
en-ZA | 0x1C09 | 7177 | |
en-TT | 0x2C09 | 11273 | |
en-GB | 0x0809 | 2057 | |
en-US | 0x0409 | 1033 | |
en-ZW | 0x3009 | 12297 | |
爱沙 |
et | 0x0425 | 1061 |
fa | 0x0429 | 1065 | |
芬兰语 | fi | 0x040B | 1035 |
fo | 0x0438 | 1080 | |
fr-fr | 0x040C | 1036 | |
fr-be | 0x080C | 2060 | |
fr-ca | 0x0C0C | 3084 | |
fr-lu | 0x140C | 5132 | |
fr-ch | 0x100C | 4108 | |
盖尔语-爱尔兰 | gd-ie | 0x083C | 2108 |
盖尔语-苏格兰 | gd | 0x043C | 1084 |
de-DE | 0x0407 | 1031 | |
de-DE_phoneb | 0x10407 | ||
de-AT | 0x0C07 | 3079 | |
de-LI | 0x1407 | 5127 | |
de-LU | 0x1007 | 4103 | |
de-CH | 0x0807 | 2055 | |
dsb | |||
dsb_DE | |||
dv | |||
dv_MF | |||
el | 0x0408 | 1032 | |
el-GR | 0x0408 | 1032 | |
he | 0x040D | 1037 | |
hi | 0x0439 | 1081 | |
匈牙 |
hu | 0x040E | 1038 |
冰岛语 | is | 0x040F | 1039 |
id | 0x0421 | 1057 | |
it-it | 0x0410 | 1040 | |
it-ch | 0x0810 | 2064 | |
ja | 0x0411 | 1041 | |
ko | 0x0412 | 1042 | |
lv | 0x0426 | 1062 | |
lt | 0x0427 | 1063 | |
马其顿 | mk | 0x042F | 1071 |
马来语-马来 |
ms-my | 0x043E | 1086 |
马来语- |
ms-bn | 0x083E | 2110 |
马耳 |
mt | 0x043A | 1082 |
马拉 |
mr | 0x044E | 1102 |
挪威- |
nb-no | 0x0414 | 1044 |
挪威- |
nn-no | 0x0814 | 2068 |
pl | 0x0415 | 1045 | |
pt-pt | 0x0816 | 2070 | |
pt-br | 0x0416 | 1046 | |
罗曼什语 | rm | 0x0417 | 1047 |
罗马 |
ro | 0x0418 | 1048 |
罗马 |
ro-mo | 0x0818 | 2072 |
ru | 0x0419 | 1049 | |
ru-mo | 0x0819 | 2073 | |
sa | 0x044F | 1103 | |
sr-sp | 0x0C1A | 3098 | |
sr-sp | 0x081A | 2074 | |
tn | 0x0432 | 1074 | |
斯洛 |
sl | 0x0424 | 1060 |
斯洛 |
sk | 0x041B | 1051 |
sb | 0x042E | 1070 | |
es-es | 0x0C0A | 3082 | |
0x040A | 1034 | ||
es-ar | 0x2C0A | 11274 | |
es-bo | 0x400A | 16394 | |
es-cl | 0x340A | 13322 | |
es-co | 0x240A | 9226 | |
es-cr | 0x140A | 5130 | |
es-do | 0x1C0A | 7178 | |
es-ec | 0x300A | 12298 | |
es-gt | 0x100A | 4106 | |
es-hn | 0x480A | 18442 | |
es-mx | 0x080A | 2058 | |
es-ni | 0x4C0A | 19466 | |
es-pa | 0x180A | 6154 | |
es-pe | 0x280A | 10250 | |
es-pr | 0x500A | 20490 | |
es-py | 0x3C0A | 15370 | |
es-sv | 0x440A | 17418 | |
es-uy | 0x380A | 14346 | |
es-ve | 0x200A | 8202 | |
st | 0x0430 | 1072 | |
斯瓦 |
sw | 0x0441 | 1089 |
sv-se | 0x041D | 1053 | |
sv-fi | 0x081D | 2077 | |
ta | 0x0449 | 1097 | |
鞑靼语 | tt | 0X0444 | 1092 |
th | 0x041E | 1054 | |
tr | 0x041F | 1055 | |
ts | 0x0431 | 1073 | |
乌克兰语 | uk | 0x0422 | 1058 |
乌都语 | ur | 0x0420 | 1056 |
乌兹别克语- |
uz-uz | 0x0843 | 2115 |
乌兹别克语- |
uz-uz | 0x0443 | 1091 |
vi | 0x042A | 1066 | |
xh | 0x0434 | 1076 | |
yi | 0x043D | 1085 | |
zu | 0x0435 | 1077 |
参 见
编辑
外部 链接
编辑
参考 文献
编辑
- ^ In IBM developerworks网站
王 华东:“浅 析 Linux的 国 际化与本 地 化 机 制 ”. [2014-10-31]. (原始 内容 存 档于2014-10-31). - ^ A Quick Primer On Unicode and Software Internationalization Under Linux and UNIX by Ed Trager. [2014-11-30]. (
原始 内容 存 档于2014-12-04).