8000 [Translation] avoid creating cache files for fallback locales. · symfony/symfony@22425b2 · GitHub
[go: up one dir, main page]

Skip to content
Sign in

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 22425b2

Browse files
committed
[Translation] avoid creating cache files for fallback locales.
1 parent 85ae039 commit 22425b2

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/Symfony/Component/Translation/Tests/TranslatorCacheTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,17 @@ public function testDifferentTranslatorsForSameLocaleDoNotOverwriteEachOthersCac
149149
$this->assertEquals('OK', $translator->trans($msgid), '-> the cache was overwritten by another translator instance in '.($debug ? 'debug' : 'production'));
150150
}
151151

152+
public function testGeneratedCacheFilesAreOnlyBelongRequestedLocales()
153+
{
154+
$translator = new Translator('a', null, $this->tmpDir);
155+
$translator->setFallbackLocales(array('b'));
156+
$translator->trans('bar');
157+
158+
$cachedFiles = glob($this->tmpDir.'/*.php');
159+
160+
$this->assertCount(1, $cachedFiles);
161+
}
162+
152163
public function testDifferentCacheFilesAreUsedForDifferentSetsOfFallbackLocales()
153164
{
154165
/*

src/Symfony/Component/Translation/Translator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ private function loadFallbackCatalogues($locale)
420420

421421
foreach ($this->computeFallbackLocales($locale) as $fallback) {
422422
if (!isset($this->catalogues[$fallback])) {
423-
$this->loadCatalogue($fallback);
423+
$this->initializeCatalogue($fallback);
424424
}
425425

426426
$fallbackCatalogue = new MessageCatalogue($fallback, $this->catalogues[$fallback]->all());

0 commit comments

Comments
 (0)
0