Skip to content

Commit

Permalink
fixed fallback locale
Browse files Browse the repository at this point in the history
  • Loading branch information
pkraeutli authored and fabpot committed Oct 19, 2012
1 parent bb0d402 commit 965734e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
6 changes: 1 addition & 5 deletions src/Symfony/Component/Locale/Locale.php
Expand Up @@ -285,12 +285,8 @@ public static function getIcuDataDirectory()
*/
protected static function getFallbackLocale($locale)
{
if ($locale === self::getDefault()) {
return null;
}

if (false === $pos = strrpos($locale, '_')) {
return self::getDefault();
return null;
}

return substr($locale, 0, $pos);
Expand Down
9 changes: 9 additions & 0 deletions src/Symfony/Component/Locale/Tests/LocaleTest.php
Expand Up @@ -19,6 +19,9 @@ class LocaleTest extends LocaleTestCase
public function testGetDisplayCountriesReturnsFullListForSubLocale()
{
$this->skipIfIntlExtensionIsNotLoaded();

Locale::setDefault('de_CH');

$countriesDe = Locale::getDisplayCountries('de');
$countriesDeCh = Locale::getDisplayCountries('de_CH');

Expand All @@ -30,6 +33,9 @@ public function testGetDisplayCountriesReturnsFullListForSubLocale()
public function testGetDisplayLanguagesReturnsFullListForSubLocale()
{
$this->skipIfIntlExtensionIsNotLoaded();

Locale::setDefault('de_CH');

$languagesDe = Locale::getDisplayLanguages('de');
$languagesDeCh = Locale::getDisplayLanguages('de_CH');

Expand All @@ -41,6 +47,9 @@ public function testGetDisplayLanguagesReturnsFullListForSubLocale()
public function testGetDisplayLocalesReturnsFullListForSubLocale()
{
$this->skipIfIntlExtensionIsNotLoaded();

Locale::setDefault('de_CH');

$localesDe = Locale::getDisplayLocales('de');
$localesDeCh = Locale::getDisplayLocales('de_CH');

Expand Down

0 comments on commit 965734e

Please sign in to comment.