Since symfony 2.3 country names can be translated using Intl and the RegionBundle.
The default returned array of getCountryNames()
looks like this:
=> array('AF' => 'Afghanistan', ...)
If you're only interested in the country names use something like this:
use Symfony\Component\Intl\Intl;
// get all country names in locale "locale"
$countries = array_values(Intl::getRegionBundle()->getCountryNames('de'));
// get all country names for current locale
$countries = array_values(Intl::getRegionBundle()->getCountryNames());
... in case you just want to translate an array using the translator.
$translator = $this->get('translator');
foreach ($countries as $key => $country) {
$countries[$key] = $translator->trans($country, array(), null, 'de');
}
See the Translator API Documentation and read the cookbook chapter Translations.