When I save countries into my database I use the international abbreviation.
How do I convert this abbreviation with zend_locale
to the full country name?
Here is the method. It tries to use the browser's locale and defaults to US English if that fails.
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']);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With