8000 bug #15516 [Translator][warmup][fallback locales] fixed missing cache… · symfony/symfony@2ae2714 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2ae2714

Browse files
committed
bug #15516 [Translator][warmup][fallback locales] fixed missing cache file generation. (aitboudad)
This PR was merged into the 2.7 branch. Discussion ---------- [Translator][warmup][fallback locales] fixed missing cache file generation. | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Fixed tickets | #15364 | Tests pass? | yes | License | MIT Commits ------- cade651 [Translator][warmup][fallback locales] fixed missing cache file generation.
2 parents 249d130 + cade651 commit 2ae2714

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/Symfony/Bundle/FrameworkBundle/Tests/Translation/TranslatorTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ public function testWarmup()
273273

274274
// prime the cache
275275
$translator = $this->getTranslator($loader, array('cache_dir' => $this->tmpDir, 'resource_files' => $resourceFiles), 'yml');
276-
$translator->setLocale('fr');
276+
$translator->setFallbackLocales(array('fr'));
277277
$translator->warmup($this->tmpDir);
278278

279279
$loader = $this->getMock('Symfony\Component\Translation\Loader\LoaderInterface');
@@ -283,6 +283,7 @@ public function testWarmup()
283283

284284
$translator = $this->getTranslator($loader, array('cache_dir' => $this->tmpDir, 'resource_files' => $resourceFiles), 'yml');
285285
$translator->setLocale('fr');
286+
$translator->setFallbackLocales(array('fr'));
286287
$this->assertEquals('répertoire', $translator->trans('folder'));
287288
}
288289

src/Symfony/Bundle/FrameworkBundle/Translation/Translator.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,13 @@ public function warmUp($cacheDir)
8282
return;
8383
}
8484

85-
foreach ($this->resourceLocales as $locale) {
85+
$locales = array_merge($this->getFallbackLocales(), array($this->getLocale()), $this->resourceLocales);
86+
foreach (array_unique($locales) as $locale) {
87+
// reset catalogue in case it's already loaded during the dump of the other locales.
88+
if (isset($this->catalogues[$locale])) {
89+
unset($this->catalogues[$locale]);
90+
}
91+
8692
$this->loadCatalogue($locale);
8793
}
8894
}

0 commit comments

Comments
 (0)
0