symfony/symfony — Issue #3090: Locale::getDisplayCountries() does not return all countries for 5-letter locales
Author: pkraeutli
Created: 2012-01-11 10:53:44+00:00
State: open

When a 5-letter locale (e.g. de_CH) ist set, Symfony\Component\Locale\Locale::getDisplayCountries() does not return the full country list but only the countries that are special for the specific locale.

This is only the case when there is in fact a special resource file for this locale. For fr_CH for instance, fr is used as the fallback and the full list is returned.

Something like the following code seems to solve the issue, although it looks a little hacky so I am not sure if this is the right way.

namespace Symfony\Component\Locale;

class Locale extends \Locale
{
static public function getDisplayCountries($locale)
{
// ...

if (strlen($locale) == 5) {
$countries = self::getDisplayCountries(substr($locale, 0, 2));
} else {
$countries = array();
}

// ...
}
}