From 11ff24a66577fb8aefc4ad5b3ed9c646074f3981 Mon Sep 17 00:00:00 2001 From: Roland Franssen Date: Tue, 7 May 2019 19:46:35 +0200 Subject: [PATCH] [Intl] Fix root fallback locale --- .../Data/Generator/LocaleDataGenerator.php | 46 +++++++------------ .../Data/Generator/RegionDataGenerator.php | 21 ++++++--- src/Symfony/Component/Intl/Locale.php | 8 ++-- .../Intl/Resources/bin/update-data.php | 45 ++++-------------- .../Intl/Resources/data/locales/az_AZ.json | 3 -- .../Intl/Resources/data/locales/bs_BA.json | 3 -- .../Intl/Resources/data/locales/en_NH.json | 3 -- .../Intl/Resources/data/locales/en_RH.json | 3 -- .../Intl/Resources/data/locales/ff_CM.json | 3 -- .../Intl/Resources/data/locales/ff_GN.json | 3 -- .../Intl/Resources/data/locales/ff_MR.json | 3 -- .../Intl/Resources/data/locales/ff_SN.json | 3 -- .../Intl/Resources/data/locales/in.json | 3 -- .../Intl/Resources/data/locales/in_ID.json | 3 -- .../Intl/Resources/data/locales/iw.json | 3 -- .../Intl/Resources/data/locales/iw_IL.json | 3 -- .../Intl/Resources/data/locales/mo.json | 3 -- .../Intl/Resources/data/locales/no.json | 3 -- .../Intl/Resources/data/locales/no_NO.json | 3 -- .../Intl/Resources/data/locales/no_NO_NY.json | 3 -- .../Intl/Resources/data/locales/pa_IN.json | 3 -- .../Intl/Resources/data/locales/pa_PK.json | 3 -- .../Intl/Resources/data/locales/sh.json | 3 -- .../Intl/Resources/data/locales/sh_BA.json | 3 -- .../Intl/Resources/data/locales/sh_CS.json | 3 -- .../Intl/Resources/data/locales/sh_YU.json | 3 -- .../Intl/Resources/data/locales/sr_BA.json | 3 -- .../Intl/Resources/data/locales/sr_CS.json | 3 -- .../Resources/data/locales/sr_Cyrl_CS.json | 3 -- .../Resources/data/locales/sr_Cyrl_YU.json | 3 -- .../Resources/data/locales/sr_Latn_CS.json | 3 -- .../Resources/data/locales/sr_Latn_YU.json | 3 -- .../Intl/Resources/data/locales/sr_ME.json | 3 -- .../Intl/Resources/data/locales/sr_RS.json | 3 -- .../Intl/Resources/data/locales/sr_XK.json | 3 -- .../Intl/Resources/data/locales/sr_YU.json | 3 -- .../Intl/Resources/data/locales/tl.json | 3 -- .../Intl/Resources/data/locales/tl_PH.json | 3 -- .../Intl/Resources/data/locales/uz_AF.json | 3 -- .../Intl/Resources/data/locales/uz_UZ.json | 3 -- .../Intl/Resources/data/locales/zh_CN.json | 3 -- .../Intl/Resources/data/locales/zh_HK.json | 3 -- .../Intl/Resources/data/locales/zh_MO.json | 3 -- .../Intl/Resources/data/locales/zh_SG.json | 3 -- .../Intl/Resources/data/locales/zh_TW.json | 3 -- .../Component/Intl/Tests/LocaleTest.php | 24 ++++++++++ 46 files changed, 68 insertions(+), 199 deletions(-) delete mode 100644 src/Symfony/Component/Intl/Resources/data/locales/az_AZ.json delete mode 100644 src/Symfony/Component/Intl/Resources/data/locales/bs_BA.json delete mode 100644 src/Symfony/Component/Intl/Resources/data/locales/en_NH.json delete mode 100644 src/Symfony/Component/Intl/Resources/data/locales/en_RH.json delete mode 100644 src/Symfony/Component/Intl/Resources/data/locales/ff_CM.json delete mode 100644 src/Symfony/Component/Intl/Resources/data/locales/ff_GN.json delete mode 100644 src/Symfony/Component/Intl/Resources/data/locales/ff_MR.json delete mode 100644 src/Symfony/Component/Intl/Resources/data/locales/ff_SN.json delete mode 100644 src/Symfony/Component/Intl/Resources/data/locales/in.json delete mode 100644 src/Symfony/Component/Intl/Resources/data/locales/in_ID.json delete mode 100644 src/Symfony/Component/Intl/Resources/data/locales/iw.json delete mode 100644 src/Symfony/Component/Intl/Resources/data/locales/iw_IL.json delete mode 100644 src/Symfony/Component/Intl/Resources/data/locales/mo.json delete mode 100644 src/Symfony/Component/Intl/Resources/data/locales/no.json delete mode 100644 src/Symfony/Component/Intl/Resources/data/locales/no_NO.json delete mode 100644 src/Symfony/Component/Intl/Resources/data/locales/no_NO_NY.json delete mode 100644 src/Symfony/Component/Intl/Resources/data/locales/pa_IN.json delete mode 100644 src/Symfony/Component/Intl/Resources/data/locales/pa_PK.json delete mode 100644 src/Symfony/Component/Intl/Resources/data/locales/sh.json delete mode 100644 src/Symfony/Component/Intl/Resources/data/locales/sh_BA.json delete mode 100644 src/Symfony/Component/Intl/Resources/data/locales/sh_CS.json delete mode 100644 src/Symfony/Component/Intl/Resources/data/locales/sh_YU.json delete mode 100644 src/Symfony/Component/Intl/Resources/data/locales/sr_BA.json delete mode 100644 src/Symfony/Component/Intl/Resources/data/locales/sr_CS.json delete mode 100644 src/Symfony/Component/Intl/Resources/data/locales/sr_Cyrl_CS.json delete mode 100644 src/Symfony/Component/Intl/Resources/data/locales/sr_Cyrl_YU.json delete mode 100644 src/Symfony/Component/Intl/Resources/data/locales/sr_Latn_CS.json delete mode 100644 src/Symfony/Component/Intl/Resources/data/locales/sr_Latn_YU.json delete mode 100644 src/Symfony/Component/Intl/Resources/data/locales/sr_ME.json delete mode 100644 src/Symfony/Component/Intl/Resources/data/locales/sr_RS.json delete mode 100644 src/Symfony/Component/Intl/Resources/data/locales/sr_XK.json delete mode 100644 src/Symfony/Component/Intl/Resources/data/locales/sr_YU.json delete mode 100644 src/Symfony/Component/Intl/Resources/data/locales/tl.json delete mode 100644 src/Symfony/Component/Intl/Resources/data/locales/tl_PH.json delete mode 100644 src/Symfony/Component/Intl/Resources/data/locales/uz_AF.json delete mode 100644 src/Symfony/Component/Intl/Resources/data/locales/uz_UZ.json delete mode 100644 src/Symfony/Component/Intl/Resources/data/locales/zh_CN.json delete mode 100644 src/Symfony/Component/Intl/Resources/data/locales/zh_HK.json delete mode 100644 src/Symfony/Component/Intl/Resources/data/locales/zh_MO.json delete mode 100644 src/Symfony/Component/Intl/Resources/data/locales/zh_SG.json delete mode 100644 src/Symfony/Component/Intl/Resources/data/locales/zh_TW.json diff --git a/src/Symfony/Component/Intl/Data/Generator/LocaleDataGenerator.php b/src/Symfony/Component/Intl/Data/Generator/LocaleDataGenerator.php index baa766d76493..d4f6ab4acccf 100644 --- a/src/Symfony/Component/Intl/Data/Generator/LocaleDataGenerator.php +++ b/src/Symfony/Component/Intl/Data/Generator/LocaleDataGenerator.php @@ -14,9 +14,6 @@ use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\Intl\Data\Bundle\Compiler\BundleCompilerInterface; use Symfony\Component\Intl\Data\Bundle\Reader\BundleEntryReaderInterface; -use Symfony\Component\Intl\Data\Provider\LanguageDataProvider; -use Symfony\Component\Intl\Data\Provider\RegionDataProvider; -use Symfony\Component\Intl\Data\Provider\ScriptDataProvider; use Symfony\Component\Intl\Data\Util\LocaleScanner; use Symfony\Component\Intl\Exception\MissingResourceException; use Symfony\Component\Intl\Locale; @@ -31,23 +28,11 @@ */ class LocaleDataGenerator extends AbstractDataGenerator { - private $languageDataProvider; - private $scriptDataProvider; - private $regionDataProvider; private $locales; private $localeAliases; private $fallbackMapping; private $fallbackCache = []; - public function __construct(BundleCompilerInterface $compiler, $dirName, LanguageDataProvider $languageDataProvider, ScriptDataProvider $scriptDataProvider, RegionDataProvider $regionDataProvider) - { - parent::__construct($compiler, $dirName); - - $this->languageDataProvider = $languageDataProvider; - $this->scriptDataProvider = $scriptDataProvider; - $this->regionDataProvider = $regionDataProvider; - } - /** * {@inheritdoc} */ @@ -66,8 +51,12 @@ protected function scanLocales(LocaleScanner $scanner, $sourceDir) protected function compileTemporaryBundles(BundleCompilerInterface $compiler, $sourceDir, $tempDir) { $filesystem = new Filesystem(); - $filesystem->mkdir($tempDir.'/lang'); + $filesystem->mkdir([ + $tempDir.'/lang', + $tempDir.'/region', + ]); $compiler->compile($sourceDir.'/lang', $tempDir.'/lang'); + $compiler->compile($sourceDir.'/region', $tempDir.'/region'); } /** @@ -83,19 +72,14 @@ protected function preGenerate() */ protected function generateDataForLocale(BundleEntryReaderInterface $reader, $tempDir, $displayLocale) { - // Generate aliases, needed to enable proper fallback from alias to its - // target + // Don't generate aliases, as they are resolved during runtime if (isset($this->localeAliases[$displayLocale])) { - return ['%%ALIAS' => $this->localeAliases[$displayLocale]]; + return; } // Generate locale names for all locales that have translations in // at least the language or the region bundle - try { - $displayFormat = $reader->readEntry($tempDir.'/lang', $displayLocale, ['localeDisplayPattern']); - } catch (MissingResourceException $e) { - $displayFormat = $reader->readEntry($tempDir.'/lang', 'root', ['localeDisplayPattern']); - } + $displayFormat = $reader->readEntry($tempDir.'/lang', $displayLocale, ['localeDisplayPattern']); $pattern = $displayFormat['pattern'] ?? '{0} ({1})'; $separator = $displayFormat['separator'] ?? '{0}, {1}'; $localeNames = []; @@ -110,7 +94,7 @@ protected function generateDataForLocale(BundleEntryReaderInterface $reader, $te // Each locale name has the form: "Language (Script, Region, Variant1, ...) // Script, Region and Variants are optional. If none of them is // available, the braces are not printed. - $localeNames[$locale] = $this->generateLocaleName($locale, $displayLocale, $pattern, $separator); + $localeNames[$locale] = $this->generateLocaleName($reader, $tempDir, $locale, $displayLocale, $pattern, $separator); } catch (MissingResourceException $e) { // Silently ignore incomplete locale names // In this case one should configure at least one fallback locale that is complete (e.g. English) during @@ -158,22 +142,26 @@ protected function generateDataForMeta(BundleEntryReaderInterface $reader, $temp /** * @return string */ - private function generateLocaleName($locale, $displayLocale, $pattern, $separator) + private function generateLocaleName(BundleEntryReaderInterface $reader, $tempDir, $locale, $displayLocale, $pattern, $separator) { // Apply generic notation using square brackets as described per http://cldr.unicode.org/translation/language-names - $name = str_replace(['(', ')'], ['[', ']'], $this->languageDataProvider->getName(\Locale::getPrimaryLanguage($locale), $displayLocale)); + $name = str_replace(['(', ')'], ['[', ']'], $reader->readEntry($tempDir.'/lang', $displayLocale, ['Languages', \Locale::getPrimaryLanguage($locale)])); $extras = []; // Discover the name of the script part of the locale // i.e. in zh_Hans_MO, "Hans" is the script if ($script = \Locale::getScript($locale)) { - $extras[] = str_replace(['(', ')'], ['[', ']'], $this->scriptDataProvider->getName($script, $displayLocale)); + $extras[] = str_replace(['(', ')'], ['[', ']'], $reader->readEntry($tempDir.'/lang', $displayLocale, ['Scripts', $script])); } // Discover the name of the region part of the locale // i.e. in de_AT, "AT" is the region if ($region = \Locale::getRegion($locale)) { - $extras[] = str_replace(['(', ')'], ['[', ']'], $this->regionDataProvider->getName($region, $displayLocale)); + if (!RegionDataGenerator::isValidCountryCode($region)) { + throw new MissingResourceException('Skipping "'.$locale.'" due an invalid country.'); + } + + $extras[] = str_replace(['(', ')'], ['[', ']'], $reader->readEntry($tempDir.'/region', $displayLocale, ['Countries', $region])); } if ($extras) { diff --git a/src/Symfony/Component/Intl/Data/Generator/RegionDataGenerator.php b/src/Symfony/Component/Intl/Data/Generator/RegionDataGenerator.php index 1de3c4ae571a..25deae2fa5f9 100644 --- a/src/Symfony/Component/Intl/Data/Generator/RegionDataGenerator.php +++ b/src/Symfony/Component/Intl/Data/Generator/RegionDataGenerator.php @@ -48,6 +48,20 @@ class RegionDataGenerator extends AbstractDataGenerator */ private $regionCodes = []; + public static function isValidCountryCode($region) + { + if (isset(self::$blacklist[$region])) { + return false; + } + + // WORLD/CONTINENT/SUBCONTINENT/GROUPING + if (ctype_digit($region) || \is_int($region)) { + return false; + } + + return true; + } + /** * {@inheritdoc} */ @@ -125,12 +139,7 @@ protected function generateRegionNames(ArrayAccessibleResourceBundle $localeBund $regionNames = []; foreach ($unfilteredRegionNames as $region => $regionName) { - if (isset(self::$blacklist[$region])) { - continue; - } - - // WORLD/CONTINENT/SUBCONTINENT/GROUPING - if (ctype_digit($region) || \is_int($region)) { + if (!self::isValidCountryCode($region)) { continue; } diff --git a/src/Symfony/Component/Intl/Locale.php b/src/Symfony/Component/Intl/Locale.php index 6e88c5629e00..9f810235e6f8 100644 --- a/src/Symfony/Component/Intl/Locale.php +++ b/src/Symfony/Component/Intl/Locale.php @@ -31,7 +31,7 @@ final class Locale extends \Locale * The default fallback locale is used as fallback for locales that have no * fallback otherwise. * - * @param string $locale The default fallback locale + * @param string|null $locale The default fallback locale * * @see getFallback() */ @@ -43,7 +43,7 @@ public static function setDefaultFallback($locale) /** * Returns the default fallback locale. * - * @return string The default fallback locale + * @return string|null The default fallback locale * * @see setDefaultFallback() * @see getFallback() @@ -70,7 +70,7 @@ public static function getFallback($locale) if (\function_exists('locale_parse')) { $localeSubTags = locale_parse($locale); if (1 === \count($localeSubTags)) { - if (self::$defaultFallback === $localeSubTags['language']) { + if ('root' !== self::$defaultFallback && self::$defaultFallback === $localeSubTags['language']) { return 'root'; } @@ -98,7 +98,7 @@ public static function getFallback($locale) return substr($locale, 0, $pos); } - if (self::$defaultFallback === $locale) { + if ('root' !== self::$defaultFallback && self::$defaultFallback === $locale) { return 'root'; } diff --git a/src/Symfony/Component/Intl/Resources/bin/update-data.php b/src/Symfony/Component/Intl/Resources/bin/update-data.php index 0f44c584fa53..0ec098363aa6 100644 --- a/src/Symfony/Component/Intl/Resources/bin/update-data.php +++ b/src/Symfony/Component/Intl/Resources/bin/update-data.php @@ -11,8 +11,6 @@ use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\Intl\Data\Bundle\Compiler\GenrbCompiler; -use Symfony\Component\Intl\Data\Bundle\Reader\BundleEntryReader; -use Symfony\Component\Intl\Data\Bundle\Reader\JsonBundleReader; use Symfony\Component\Intl\Data\Bundle\Writer\JsonBundleWriter; use Symfony\Component\Intl\Data\Generator\CurrencyDataGenerator; use Symfony\Component\Intl\Data\Generator\GeneratorConfig; @@ -20,9 +18,6 @@ use Symfony\Component\Intl\Data\Generator\LocaleDataGenerator; use Symfony\Component\Intl\Data\Generator\RegionDataGenerator; use Symfony\Component\Intl\Data\Generator\ScriptDataGenerator; -use Symfony\Component\Intl\Data\Provider\LanguageDataProvider; -use Symfony\Component\Intl\Data\Provider\RegionDataProvider; -use Symfony\Component\Intl\Data\Provider\ScriptDataProvider; use Symfony\Component\Intl\Intl; use Symfony\Component\Intl\Locale; use Symfony\Component\Intl\Util\GitRepository; @@ -171,27 +166,13 @@ $compiler = new GenrbCompiler($genrb, $genrbEnv); $config = new GeneratorConfig($sourceDir.'/data', $icuVersionInDownload); $jsonDir = dirname(__DIR__).'/data'; -$targetDirs = [$jsonDir]; -$workingDirs = [$jsonDir]; $config->addBundleWriter($jsonDir, new JsonBundleWriter()); echo "Starting resource bundle compilation. This may take a while...\n"; -$filesystem->remove($workingDirs); - -foreach ($workingDirs as $targetDir) { - $filesystem->mkdir([ - $targetDir.'/'.Intl::CURRENCY_DIR, - $targetDir.'/'.Intl::LANGUAGE_DIR, - $targetDir.'/'.Intl::LOCALE_DIR, - $targetDir.'/'.Intl::REGION_DIR, - $targetDir.'/'.Intl::SCRIPT_DIR, - ]); -} - // We don't want to use fallback to English during generation -Locale::setDefaultFallback(null); +Locale::setDefaultFallback('root'); echo "Generating language data...\n"; @@ -215,14 +196,7 @@ echo "Generating locale data...\n"; -$reader = new BundleEntryReader(new JsonBundleReader()); -$generator = new LocaleDataGenerator( - $compiler, - Intl::LOCALE_DIR, - new LanguageDataProvider($jsonDir.'/'.Intl::LANGUAGE_DIR, $reader), - new ScriptDataProvider($jsonDir.'/'.Intl::SCRIPT_DIR, $reader), - new RegionDataProvider($jsonDir.'/'.Intl::REGION_DIR, $reader) -); +$generator = new LocaleDataGenerator($compiler, Intl::LOCALE_DIR); $generator->generateData($config); echo "Resource bundle compilation complete.\n"; @@ -238,18 +212,15 @@ GIT_INFO; -foreach ($targetDirs as $targetDir) { - $gitInfoFile = $targetDir.'/git-info.txt'; +$gitInfoFile = $jsonDir.'/git-info.txt'; - file_put_contents($gitInfoFile, $gitInfo); +file_put_contents($gitInfoFile, $gitInfo); - echo "Wrote $gitInfoFile.\n"; +echo "Wrote $gitInfoFile.\n"; - $versionFile = $targetDir.'/version.txt'; +$versionFile = $jsonDir.'/version.txt'; - file_put_contents($versionFile, "$icuVersionInDownload\n"); - - echo "Wrote $versionFile.\n"; -} +file_put_contents($versionFile, "$icuVersionInDownload\n"); +echo "Wrote $versionFile.\n"; echo "Done.\n"; diff --git a/src/Symfony/Component/Intl/Resources/data/locales/az_AZ.json b/src/Symfony/Component/Intl/Resources/data/locales/az_AZ.json deleted file mode 100644 index e679f6cb3b16..000000000000 --- a/src/Symfony/Component/Intl/Resources/data/locales/az_AZ.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "%%ALIAS": "az_Latn_AZ" -} diff --git a/src/Symfony/Component/Intl/Resources/data/locales/bs_BA.json b/src/Symfony/Component/Intl/Resources/data/locales/bs_BA.json deleted file mode 100644 index a4ac47a1b0f1..000000000000 --- a/src/Symfony/Component/Intl/Resources/data/locales/bs_BA.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "%%ALIAS": "bs_Latn_BA" -} diff --git a/src/Symfony/Component/Intl/Resources/data/locales/en_NH.json b/src/Symfony/Component/Intl/Resources/data/locales/en_NH.json deleted file mode 100644 index c5f5cd4e7a1c..000000000000 --- a/src/Symfony/Component/Intl/Resources/data/locales/en_NH.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "%%ALIAS": "en_VU" -} diff --git a/src/Symfony/Component/Intl/Resources/data/locales/en_RH.json b/src/Symfony/Component/Intl/Resources/data/locales/en_RH.json deleted file mode 100644 index b9952c41f1bb..000000000000 --- a/src/Symfony/Component/Intl/Resources/data/locales/en_RH.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "%%ALIAS": "en_ZW" -} diff --git a/src/Symfony/Component/Intl/Resources/data/locales/ff_CM.json b/src/Symfony/Component/Intl/Resources/data/locales/ff_CM.json deleted file mode 100644 index 4431c4faf37d..000000000000 --- a/src/Symfony/Component/Intl/Resources/data/locales/ff_CM.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "%%ALIAS": "ff_Latn_CM" -} diff --git a/src/Symfony/Component/Intl/Resources/data/locales/ff_GN.json b/src/Symfony/Component/Intl/Resources/data/locales/ff_GN.json deleted file mode 100644 index b7e3c9b3179d..000000000000 --- a/src/Symfony/Component/Intl/Resources/data/locales/ff_GN.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "%%ALIAS": "ff_Latn_GN" -} diff --git a/src/Symfony/Component/Intl/Resources/data/locales/ff_MR.json b/src/Symfony/Component/Intl/Resources/data/locales/ff_MR.json deleted file mode 100644 index e6fe2dcec2b3..000000000000 --- a/src/Symfony/Component/Intl/Resources/data/locales/ff_MR.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "%%ALIAS": "ff_Latn_MR" -} diff --git a/src/Symfony/Component/Intl/Resources/data/locales/ff_SN.json b/src/Symfony/Component/Intl/Resources/data/locales/ff_SN.json deleted file mode 100644 index 9bb9a1b6c2ac..000000000000 --- a/src/Symfony/Component/Intl/Resources/data/locales/ff_SN.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "%%ALIAS": "ff_Latn_SN" -} diff --git a/src/Symfony/Component/Intl/Resources/data/locales/in.json b/src/Symfony/Component/Intl/Resources/data/locales/in.json deleted file mode 100644 index 822ec3eefe45..000000000000 --- a/src/Symfony/Component/Intl/Resources/data/locales/in.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "%%ALIAS": "id" -} diff --git a/src/Symfony/Component/Intl/Resources/data/locales/in_ID.json b/src/Symfony/Component/Intl/Resources/data/locales/in_ID.json deleted file mode 100644 index 959ca25bf195..000000000000 --- a/src/Symfony/Component/Intl/Resources/data/locales/in_ID.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "%%ALIAS": "id_ID" -} diff --git a/src/Symfony/Component/Intl/Resources/data/locales/iw.json b/src/Symfony/Component/Intl/Resources/data/locales/iw.json deleted file mode 100644 index b2b0fbde8ae7..000000000000 --- a/src/Symfony/Component/Intl/Resources/data/locales/iw.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "%%ALIAS": "he" -} diff --git a/src/Symfony/Component/Intl/Resources/data/locales/iw_IL.json b/src/Symfony/Component/Intl/Resources/data/locales/iw_IL.json deleted file mode 100644 index 57b954709768..000000000000 --- a/src/Symfony/Component/Intl/Resources/data/locales/iw_IL.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "%%ALIAS": "he_IL" -} diff --git a/src/Symfony/Component/Intl/Resources/data/locales/mo.json b/src/Symfony/Component/Intl/Resources/data/locales/mo.json deleted file mode 100644 index ba570cd8c6d6..000000000000 --- a/src/Symfony/Component/Intl/Resources/data/locales/mo.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "%%ALIAS": "ro" -} diff --git a/src/Symfony/Component/Intl/Resources/data/locales/no.json b/src/Symfony/Component/Intl/Resources/data/locales/no.json deleted file mode 100644 index 2483677e4d4c..000000000000 --- a/src/Symfony/Component/Intl/Resources/data/locales/no.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "%%ALIAS": "nb" -} diff --git a/src/Symfony/Component/Intl/Resources/data/locales/no_NO.json b/src/Symfony/Component/Intl/Resources/data/locales/no_NO.json deleted file mode 100644 index 93d3f8186c47..000000000000 --- a/src/Symfony/Component/Intl/Resources/data/locales/no_NO.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "%%ALIAS": "nb_NO" -} diff --git a/src/Symfony/Component/Intl/Resources/data/locales/no_NO_NY.json b/src/Symfony/Component/Intl/Resources/data/locales/no_NO_NY.json deleted file mode 100644 index 2f03a04b4726..000000000000 --- a/src/Symfony/Component/Intl/Resources/data/locales/no_NO_NY.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "%%ALIAS": "nn_NO" -} diff --git a/src/Symfony/Component/Intl/Resources/data/locales/pa_IN.json b/src/Symfony/Component/Intl/Resources/data/locales/pa_IN.json deleted file mode 100644 index 998c720f45b8..000000000000 --- a/src/Symfony/Component/Intl/Resources/data/locales/pa_IN.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "%%ALIAS": "pa_Guru_IN" -} diff --git a/src/Symfony/Component/Intl/Resources/data/locales/pa_PK.json b/src/Symfony/Component/Intl/Resources/data/locales/pa_PK.json deleted file mode 100644 index d6a1a0784c03..000000000000 --- a/src/Symfony/Component/Intl/Resources/data/locales/pa_PK.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "%%ALIAS": "pa_Arab_PK" -} diff --git a/src/Symfony/Component/Intl/Resources/data/locales/sh.json b/src/Symfony/Component/Intl/Resources/data/locales/sh.json deleted file mode 100644 index 712481626504..000000000000 --- a/src/Symfony/Component/Intl/Resources/data/locales/sh.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "%%ALIAS": "sr_Latn" -} diff --git a/src/Symfony/Component/Intl/Resources/data/locales/sh_BA.json b/src/Symfony/Component/Intl/Resources/data/locales/sh_BA.json deleted file mode 100644 index 61b4214e556b..000000000000 --- a/src/Symfony/Component/Intl/Resources/data/locales/sh_BA.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "%%ALIAS": "sr_Latn_BA" -} diff --git a/src/Symfony/Component/Intl/Resources/data/locales/sh_CS.json b/src/Symfony/Component/Intl/Resources/data/locales/sh_CS.json deleted file mode 100644 index 90df436a701a..000000000000 --- a/src/Symfony/Component/Intl/Resources/data/locales/sh_CS.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "%%ALIAS": "sr_Latn_RS" -} diff --git a/src/Symfony/Component/Intl/Resources/data/locales/sh_YU.json b/src/Symfony/Component/Intl/Resources/data/locales/sh_YU.json deleted file mode 100644 index 90df436a701a..000000000000 --- a/src/Symfony/Component/Intl/Resources/data/locales/sh_YU.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "%%ALIAS": "sr_Latn_RS" -} diff --git a/src/Symfony/Component/Intl/Resources/data/locales/sr_BA.json b/src/Symfony/Component/Intl/Resources/data/locales/sr_BA.json deleted file mode 100644 index 1abbba48084f..000000000000 --- a/src/Symfony/Component/Intl/Resources/data/locales/sr_BA.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "%%ALIAS": "sr_Cyrl_BA" -} diff --git a/src/Symfony/Component/Intl/Resources/data/locales/sr_CS.json b/src/Symfony/Component/Intl/Resources/data/locales/sr_CS.json deleted file mode 100644 index ea9adc0ba7cb..000000000000 --- a/src/Symfony/Component/Intl/Resources/data/locales/sr_CS.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "%%ALIAS": "sr_Cyrl_RS" -} diff --git a/src/Symfony/Component/Intl/Resources/data/locales/sr_Cyrl_CS.json b/src/Symfony/Component/Intl/Resources/data/locales/sr_Cyrl_CS.json deleted file mode 100644 index ea9adc0ba7cb..000000000000 --- a/src/Symfony/Component/Intl/Resources/data/locales/sr_Cyrl_CS.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "%%ALIAS": "sr_Cyrl_RS" -} diff --git a/src/Symfony/Component/Intl/Resources/data/locales/sr_Cyrl_YU.json b/src/Symfony/Component/Intl/Resources/data/locales/sr_Cyrl_YU.json deleted file mode 100644 index ea9adc0ba7cb..000000000000 --- a/src/Symfony/Component/Intl/Resources/data/locales/sr_Cyrl_YU.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "%%ALIAS": "sr_Cyrl_RS" -} diff --git a/src/Symfony/Component/Intl/Resources/data/locales/sr_Latn_CS.json b/src/Symfony/Component/Intl/Resources/data/locales/sr_Latn_CS.json deleted file mode 100644 index 90df436a701a..000000000000 --- a/src/Symfony/Component/Intl/Resources/data/locales/sr_Latn_CS.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "%%ALIAS": "sr_Latn_RS" -} diff --git a/src/Symfony/Component/Intl/Resources/data/locales/sr_Latn_YU.json b/src/Symfony/Component/Intl/Resources/data/locales/sr_Latn_YU.json deleted file mode 100644 index 90df436a701a..000000000000 --- a/src/Symfony/Component/Intl/Resources/data/locales/sr_Latn_YU.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "%%ALIAS": "sr_Latn_RS" -} diff --git a/src/Symfony/Component/Intl/Resources/data/locales/sr_ME.json b/src/Symfony/Component/Intl/Resources/data/locales/sr_ME.json deleted file mode 100644 index afb199f8fe88..000000000000 --- a/src/Symfony/Component/Intl/Resources/data/locales/sr_ME.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "%%ALIAS": "sr_Latn_ME" -} diff --git a/src/Symfony/Component/Intl/Resources/data/locales/sr_RS.json b/src/Symfony/Component/Intl/Resources/data/locales/sr_RS.json deleted file mode 100644 index ea9adc0ba7cb..000000000000 --- a/src/Symfony/Component/Intl/Resources/data/locales/sr_RS.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "%%ALIAS": "sr_Cyrl_RS" -} diff --git a/src/Symfony/Component/Intl/Resources/data/locales/sr_XK.json b/src/Symfony/Component/Intl/Resources/data/locales/sr_XK.json deleted file mode 100644 index 0219f846e195..000000000000 --- a/src/Symfony/Component/Intl/Resources/data/locales/sr_XK.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "%%ALIAS": "sr_Cyrl_XK" -} diff --git a/src/Symfony/Component/Intl/Resources/data/locales/sr_YU.json b/src/Symfony/Component/Intl/Resources/data/locales/sr_YU.json deleted file mode 100644 index ea9adc0ba7cb..000000000000 --- a/src/Symfony/Component/Intl/Resources/data/locales/sr_YU.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "%%ALIAS": "sr_Cyrl_RS" -} diff --git a/src/Symfony/Component/Intl/Resources/data/locales/tl.json b/src/Symfony/Component/Intl/Resources/data/locales/tl.json deleted file mode 100644 index 943de5d92156..000000000000 --- a/src/Symfony/Component/Intl/Resources/data/locales/tl.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "%%ALIAS": "fil" -} diff --git a/src/Symfony/Component/Intl/Resources/data/locales/tl_PH.json b/src/Symfony/Component/Intl/Resources/data/locales/tl_PH.json deleted file mode 100644 index 03a1258991da..000000000000 --- a/src/Symfony/Component/Intl/Resources/data/locales/tl_PH.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "%%ALIAS": "fil_PH" -} diff --git a/src/Symfony/Component/Intl/Resources/data/locales/uz_AF.json b/src/Symfony/Component/Intl/Resources/data/locales/uz_AF.json deleted file mode 100644 index d44b235f94c8..000000000000 --- a/src/Symfony/Component/Intl/Resources/data/locales/uz_AF.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "%%ALIAS": "uz_Arab_AF" -} diff --git a/src/Symfony/Component/Intl/Resources/data/locales/uz_UZ.json b/src/Symfony/Component/Intl/Resources/data/locales/uz_UZ.json deleted file mode 100644 index 1d0a2d35e246..000000000000 --- a/src/Symfony/Component/Intl/Resources/data/locales/uz_UZ.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "%%ALIAS": "uz_Latn_UZ" -} diff --git a/src/Symfony/Component/Intl/Resources/data/locales/zh_CN.json b/src/Symfony/Component/Intl/Resources/data/locales/zh_CN.json deleted file mode 100644 index 03620084ecaf..000000000000 --- a/src/Symfony/Component/Intl/Resources/data/locales/zh_CN.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "%%ALIAS": "zh_Hans_CN" -} diff --git a/src/Symfony/Component/Intl/Resources/data/locales/zh_HK.json b/src/Symfony/Component/Intl/Resources/data/locales/zh_HK.json deleted file mode 100644 index dcc5f542148a..000000000000 --- a/src/Symfony/Component/Intl/Resources/data/locales/zh_HK.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "%%ALIAS": "zh_Hant_HK" -} diff --git a/src/Symfony/Component/Intl/Resources/data/locales/zh_MO.json b/src/Symfony/Component/Intl/Resources/data/locales/zh_MO.json deleted file mode 100644 index d98d40644ebf..000000000000 --- a/src/Symfony/Component/Intl/Resources/data/locales/zh_MO.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "%%ALIAS": "zh_Hant_MO" -} diff --git a/src/Symfony/Component/Intl/Resources/data/locales/zh_SG.json b/src/Symfony/Component/Intl/Resources/data/locales/zh_SG.json deleted file mode 100644 index c404a160bbaa..000000000000 --- a/src/Symfony/Component/Intl/Resources/data/locales/zh_SG.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "%%ALIAS": "zh_Hans_SG" -} diff --git a/src/Symfony/Component/Intl/Resources/data/locales/zh_TW.json b/src/Symfony/Component/Intl/Resources/data/locales/zh_TW.json deleted file mode 100644 index 721267a6b00a..000000000000 --- a/src/Symfony/Component/Intl/Resources/data/locales/zh_TW.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "%%ALIAS": "zh_Hant_TW" -} diff --git a/src/Symfony/Component/Intl/Tests/LocaleTest.php b/src/Symfony/Component/Intl/Tests/LocaleTest.php index ff908cbcabd0..fd998612a7ea 100644 --- a/src/Symfony/Component/Intl/Tests/LocaleTest.php +++ b/src/Symfony/Component/Intl/Tests/LocaleTest.php @@ -46,4 +46,28 @@ public function testGetFallback($expected, $locale) { $this->assertSame($expected, Locale::getFallback($locale)); } + + public function testNoDefaultFallback() + { + $prev = Locale::getDefaultFallback(); + Locale::setDefaultFallback(null); + + $this->assertSame('nl', Locale::getFallback('nl_NL')); + $this->assertNull(Locale::getFallback('nl')); + $this->assertNull(Locale::getFallback('root')); + + Locale::setDefaultFallback($prev); + } + + public function testDefaultRootFallback() + { + $prev = Locale::getDefaultFallback(); + Locale::setDefaultFallback('root'); + + $this->assertSame('nl', Locale::getFallback('nl_NL')); + $this->assertSame('root', Locale::getFallback('nl')); + $this->assertNull(Locale::getFallback('root')); + + Locale::setDefaultFallback($prev); + } }