Skip to content

Commit

Permalink
[Translator][warmup][fallback locales] fixed missing cache file gener…
Browse files Browse the repository at this point in the history
…ation.
  • Loading branch information
aitboudad committed Sep 9, 2015
1 parent 6b08d3e commit cade651
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Expand Up @@ -273,7 +273,7 @@ public function testWarmup()

// 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');
Expand All @@ -283,6 +283,7 @@ public function testWarmup()

$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'));
}

Expand Down
Expand Up @@ -82,7 +82,13 @@ public function warmUp($cacheDir)
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);
}
}
Expand Down

0 comments on commit cade651

Please sign in to comment.