I\'m triying to convert, using PHP, 2 characters country code (ISO 3166-1) to country names, or intl country codes, so I can translate the country name.
Using Loca
Maybe a bit late...
I wrote a small library in order to do this and some other ISO related things.
https://github.com/php-components/isocodes
Would be great to get some feedback or even pull requests in order to impove that library.
use ISOCodes\ISO3166_1\Adapter\Json as ISO3166_1Adapter;
$countryAdapter = new ISO3166_1Adapter();
// Get the country with alpha-2 code 'NL'
$country = $countryAdapter->get('nl');
if (null === $country) {
die('Country not found!');
}
// Get the french (fr) name.
echo $country->getName('fr');
The result would be Pays-Bas
You can use alpha-2, alpha-3 or numeric code to do the country search.