G. *_*lde 4 php zend-framework internationalization zend-locale
当我将国家/地区保存到我的数据库中时,我使用国际缩写.
如何将此缩写转换zend_locale为完整的国家/地区名称?
这是方法.它尝试使用浏览器的语言环境,如果失败则默认使用美国英语.
try {
$locale = new Zend_Locale(Zend_Locale::BROWSER);
$countries = $locale->getTranslationList('Territory', Zend_Locale::BROWSER, 2);
} catch (exception $e) {
$locale = new Zend_Locale('en_US');
$countries = $locale->getTranslationList('Territory', 'en_US', 2);
}
asort($countries, SORT_LOCALE_STRING);
// Unset invalid countries
// SU = USSR
// ZZ = Unknown or Invalid Region
// VD = North Vietnam
// DD = East Germany
unset($countries['SU'], $countries['ZZ'], $countries['VD'], $countries['DD']);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5632 次 |
| 最近记录: |