php en_UK 是非法语言环境吗?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7296262/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 02:25:07  来源:igfitidea点击:

Is en_UK an illegal locale?

phpzend-frameworklocale

提问by markus

So far I had always used 'en_UK' for British English. Today I got an error when using it with Zend Framework because the locale is not included in the long list of recognized locales.

到目前为止,我一直对英式英语使用“en_UK”。今天我在使用 Zend Framework 时遇到错误,因为该语言环境未包含在已识别语言环境的长列表中。

Here's just a short extract of that list:

这是该列表的简短摘录:

'ee_GH' => true, 'ee_TG' => true, 'ee'    => true, 'el_CY' => true, 'el_GR' => true,
'el'    => true, 'en_AS' => true, 'en_AU' => true, 'en_BE' => true, 'en_BW' => true,
'en_BZ' => true, 'en_CA' => true, 'en_GB' => true, 'en_GU' => true, 'en_HK' => true,
'en_IE' => true, 'en_IN' => true, 'en_JM' => true, 'en_MH' => true, 'en_MP' => true,
'en_MT' => true, 'en_NA' => true, 'en_NZ' => true, 'en_PH' => true, 'en_PK' => true,
'en_SG' => true, 'en_TT' => true, 'en_UM' => true, 'en_US' => true, 'en_VI' => true,
'en_ZA' => true, 'en_ZW' => true, 'en'    => true, 'eo'    => true, 'es_AR' => true,
'es_BO' => true, 'es_CL' => true, 'es_CO' => true, 'es_CR' => true, 'es_DO' => true,

As you can see, there are all kinds of territories with English language and there is also an entry 'en_GB' which I assume stands for Great Britain... but there is no 'en_UK'. Is that just a 'bug' in Zend Framework or is there another reason for that?

正如您所看到的,有各种使用英语的领土,还有一个条目“en_GB”,我认为它代表英国……但没有“en_UK”。这只是 Zend Framework 中的一个“错误”还是有其他原因?

回答by martin clayton

The correct country code is en_GB. Locales use ISO 3166-1 for country codes. The wikipedia writeupincludes:

正确的国家代码是en_GB. 语言环境使用 ISO 3166-1 作为国家/地区代码。在维基百科的书面记录包括:

The codes are chosen, according to the ISO 3166/MA, "to reflect the significant, unique component of the country name in order to allow a visual association between country name and country code".[7] For this reason, common components of country names like "Republic", "Kingdom", "United", "Federal" or "Democratic" are normally not used for deriving the code elements. As a consequence, for example, the United Kingdom is officially assigned the alpha-2 code GB rather than UK, based on its official name "United Kingdom of Great Britain and Northern Ireland" (although UK is reserved on the request of the United Kingdom).

根据 ISO 3166/MA,选择代码是为了“反映国家名称的重要、独特的组成部分,以便在国家名称和国家代码之间建立视觉关联”。 [7] 出于这个原因,通常不使用“Republic”、“Kingdom”、“United”、“Federal”或“Democratic”等国名的常见成分来推导代码元素。因此,例如,根据其官方名称“大不列颠及北爱尔兰联合王国”,英国被正式分配了 alpha-2 代码 GB 而不是 UK(尽管应英国的要求保留了 UK )。

回答by GolezTrol

It is indeed a common (?) mistake. en_UK is wrong. The ISO country code for the UK is GB, making the language tag en_GB.

这确实是一个常见的(?)错误。en_UK 是错误的。英国的 ISO 国家代码是 GB,使语言标记为 en_GB。

回答by Andreas

Imperfect implementations

Starting in 1985, ISO 3166-1 alpha-2 codes have been used in the Domain Name System as country code top-level domains (ccTLDs). The Internet Assigned Numbers Authority currently assigns the ccTLDs mostly following the alpha-2 codes, but with a few exceptions.[9] For example, the United Kingdom, whose alpha-2 code is GB, uses .uk instead of .gb as its ccTLD, as UK is currently exceptionally reserved in ISO 3166-1 on the request of the United Kingdom.

不完美的实现

从 1985 年开始,ISO 3166-1 alpha-2 代码已在域名系统中用作国家代码顶级域 (ccTLD)。互联网号码分配机构目前主要按照 alpha-2 代码分配 ccTLD,但也有一些例外。 [9] 例如,英国的 alpha-2 代码为 GB,使用 .uk 而不是 .gb 作为其 ccTLD,因为英国目前应英国的要求在 ISO 3166-1 中特别保留。

According to wikipedia http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2.

根据维基百科http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2

So apparently it's an old thing that has stuck or something like that.

很明显,这是一个卡住的旧东西或类似的东西。

EDIT: martin clayton found a better answer.

编辑:马丁·克莱顿找到了更好的答案。

回答by Linguist

You cannot simply invent locales! They are already defined. So "en-gb" is British English, whereas "en-us" is American English. If you use "en-uk", you are just making up a code.

你不能简单地发明语言环境!它们已经被定义。所以“en-gb”是英式英语,而“en-us”是美式英语。如果您使用“en-uk”,您只是在编造一个代码。

As to why the official code is "en-gb" and not "en-uk", I think basically because there is no such thing as United Kingdom English. The language variant is British. Note that the difference between Great Britain and the United Kingdom is:

至于为什么官方代码是“en-gb”而不是“en-uk”,我想基本上是因为没有英国英语这样的东西。语言变体是英国的。请注意,英国和英国的区别在于:

UK = GB + Northern Ireland

英国 = GB + 北爱尔兰

So by naming the variant "en-UK" it's as if you are saying that you want to include the way they speak in Northern Ireland within this category. But why would you want to do that? From a linguistic perspective it makes no sense, as Northern Ireland English is closer to Irish English (en-IE) than British English.

因此,通过将变体命名为“en-UK”,就好像您是在说您想将他们在北爱尔兰的说话方式包括在此类别中。但是你为什么要这样做呢?从语言的角度来看,这是没有意义的,因为北爱尔兰英语比英国英语更接近爱尔兰英语 (en-IE)。

回答by Mouna Cheikhna

the correct country code in ISO 3166 for the United Kingdom of Great Britain and Northern Ireland is for some reason "GB", so the locale code should be en_GB, and not en_UK as noted here.

由于某种原因,大不列颠及北爱尔兰联合王国的 ISO 3166 中正确的国家/地区代码为“GB”,因此区域设置代码应为 en_GB,而不是此处所述的en_UK 。

en_GB is also used by glibc, gnome, kde, etc

glibc、gnome、kde 等也使用 en_GB

Also i like the fact that many previous bug fixes in opensource projects are related to this like in apache http 1.3and roundcube project

此外,我喜欢开源项目中许多以前的错误修复都与此相关的事实,例如在apache http 1.3roundcube 项目中