[Translation] avoid creating cache files for fallback locales.

This commit is contained in:
Abdellatif Ait boudad 2017-04-03 16:48:48 +01:00
parent 85ae039cd0
commit 22425b2692
2 changed files with 12 additions and 1 deletions

View File

@ -149,6 +149,17 @@ class TranslatorCacheTest extends TestCase
$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()
{
/*

View File

@ -420,7 +420,7 @@ EOF
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());