当我将国家/地区保存到我的数据库中时,我使用国际缩写。
如何将带有 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']);
关于php - 带有 zend 语言环境的国家名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4419524/