为什么 Zend_Locale 不支持 zh_HK 或 zh_CN 等缩写格式
我有以下代码段,并尝试使用 Zend 框架和 Zend_Locale()
做一些简单的事情。
$supported_langs = array(
'en' => 'English',
'zh_CN' => '中文(简体)',
'zh_HK' => '中國(傳統)',
'es' => 'Español',
'ja' => '日本',
'pt' => 'Português',
'de' => 'Deutsch',
'ar' => 'العربية',
'fr' => 'Française',
'ru' => 'Pусский',
'ko' => '한국의',
'hi' => 'हिन्दी',
'vi' => 'Việt'
);
echo '<pre>';
foreach ($supported_langs as $lang => $desc) {
print Zend_Locale::getTranslation($lang, 'language', 'en') . "\n";
}
echo '</pre>';
上面的输出是:
English
Spanish
Japanese
Portuguese
German
Arabic
French
Russian
Korean
Hindi
Vietnamese
zh_CN
, zh_HK< /code> 不提供输出。如果我将其中一个 zh 值更改为
zh
,它会打印出 中文,我想这是可以的,但不太有效像我希望的那样?
zh_CN 和 zh_HK 是两种不同的语言...我希望能够打印两种语言的翻译...而不会过度简化为中文...
编辑
事实证明,如果我使用 < code>zh_Hans 和 zh_Hant
然后打印出正确的结果。所以我想:
问题:为什么 Zend_Locale 不支持 zh_HK 或 zh_CN 等缩写格式?
I have the following piece of code and am trying to do something simple with the Zend framework and Zend_Locale()
$supported_langs = array(
'en' => 'English',
'zh_CN' => '中文(简体)',
'zh_HK' => '中國(傳統)',
'es' => 'Español',
'ja' => '日本',
'pt' => 'Português',
'de' => 'Deutsch',
'ar' => 'العربية',
'fr' => 'Française',
'ru' => 'Pусский',
'ko' => '한국의',
'hi' => 'हिन्दी',
'vi' => 'Việt'
);
echo '<pre>';
foreach ($supported_langs as $lang => $desc) {
print Zend_Locale::getTranslation($lang, 'language', 'en') . "\n";
}
echo '</pre>';
The output from the above is:
English
Spanish
Japanese
Portuguese
German
Arabic
French
Russian
Korean
Hindi
Vietnamese
zh_CN
, zh_HK
don't provide output. If I change one of the zh values to zh
, it prints out Chinese, which is Ok, I suppose, but doesn't quite work the way I hoped?
zh_CN and zh_HK are two different languages ... I would like to be able to print the translation for both ...without over simplifying it to just Chinese...
Edit
Turns out, if I use zh_Hans
and zh_Hant
then it prints out as correct. So I suppose:
Question: why doesn't the Zend_Locale honor the abbreviated formats like zh_HK or zh_CN?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
计算机本质上是愚蠢的,你必须告诉他们一切。 Zend_Locale 从相当多的 XML 文件中获取其信息以及其中定义的内容。您的中文代码未知,不知道“官方”正确的缩写是什么。
通过以下内容,您可以获取框架中所有支持的语言的列表。
您可以传递第二个
$locale
参数,您将获得该语言的值。默认是浏览器发送的内容。更新 zh_CN 和 zh_HK 是中国与香港的地区参考,而不是语言!台湾还有 zh_TW
Computer are inherently stupid, you have to tell them everything. Zend_Locale gets its information from quite a bunch of XML files and what is defined there. Your Chinese language codes are not known, dunno what is "officially" the correct abbreviation for this.
With the following you can pull a list with all supported languages in the framework.
You can pass a second
$locale
argument and you will get the values for the language in that language. The default is what the browser sends.UPDATE zh_CN and zh_HK are region reference for China versus Hongkong and not languages! There is also zh_TW for Taiwan