[Translator][warmup][fallback locales] fixed missing cache file generation.

This commit is contained in:
Abdellatif Ait boudad 2015-08-12 10:54:13 +00:00
parent 6b08d3eb16
commit cade651915
2 changed files with 9 additions and 2 deletions

View File

@ -273,7 +273,7 @@ class TranslatorTest extends \PHPUnit_Framework_TestCase
// prime the cache
$translator = $this->getTranslator($loader, array('cache_dir' => $this->tmpDir, 'resource_files' => $resourceFiles), 'yml');
$translator->setLocale('fr');
$translator->setFallbackLocales(array('fr'));
$translator->warmup($this->tmpDir);
$loader = $this->getMock('Symfony\Component\Translation\Loader\LoaderInterface');
@ -283,6 +283,7 @@ class TranslatorTest extends \PHPUnit_Framework_TestCase
$translator = $this->getTranslator($loader, array('cache_dir' => $this->tmpDir, 'resource_files' => $resourceFiles), 'yml');
$translator->setLocale('fr');
$translator->setFallbackLocales(array('fr'));
$this->assertEquals('répertoire', $translator->trans('folder'));
}

View File

@ -82,7 +82,13 @@ class Translator extends BaseTranslator implements WarmableInterface
return;
}
foreach ($this->resourceLocales as $locale) {
$locales = array_merge($this->getFallbackLocales(), array($this->getLocale()), $this->resourceLocales);
foreach (array_unique($locales) as $locale) {
// reset catalogue in case it's already loaded during the dump of the other locales.
if (isset($this->catalogues[$locale])) {
unset($this->catalogues[$locale]);
}
$this->loadCatalogue($locale);
}
}