Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[Translation] avoid creating cache files for fallback locales.
  • Loading branch information
aitboudad committed Apr 4, 2017
commit 22425b26923050bf4d66ee9db8caed9b1cf4f007
11 changes: 11 additions & 0 deletions src/Symfony/Component/Translation/Tests/TranslatorCacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,17 @@ public function testDifferentTranslatorsForSameLocaleDoNotOverwriteEachOthersCac
$this->assertEquals('OK', $translator->trans($msgid), '-> the cache was overwritten by another translator instance in '.($debug ? 'debug' : 'production'));
}

public function testGeneratedCacheFilesAreOnlyBelongRequestedLocales()
{
$translator = new Translator('a', null, $this->tmpDir);
$translator->setFallbackLocales(array('b'));
$translator->trans('bar');

$cachedFiles = glob($this->tmpDir.'/*.php');

$this->assertCount(1, $cachedFiles);
}

public function testDifferentCacheFilesAreUsedForDifferentSetsOfFallbackLocales()
{
/*
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Translation/Translator.php
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ private function loadFallbackCatalogues($locale)

foreach ($this->computeFallbackLocales($locale) as $fallback) {
if (!isset($this->catalogues[$fallback])) {
$this->loadCatalogue($fallback);
$this->initializeCatalogue($fallback);
}

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