[FrameworkBundle][Translation][debug mode] refresh cache when resources is changed.

This commit is contained in:
Abdellatif Ait boudad 2015-03-21 21:30:03 +00:00
parent d1131dbf93
commit e36f1a70e1
2 changed files with 18 additions and 0 deletions

View File

@ -122,6 +122,12 @@ class TranslatorTest extends \PHPUnit_Framework_TestCase
$translator->setLocale('fr');
$this->assertEquals('répertoire', $translator->trans('folder'));
// refresh cache when resources is changed in debug mode.
$translator = $this->getTranslator($loader, array('cache_dir' => $this->tmpDir, 'debug' => true), array(), 'yml');
$translator->setLocale('fr');
$this->assertEquals('folder', $translator->trans('folder'));
}
public function testLoadRessourcesWithoutCaching()

View File

@ -63,6 +63,18 @@ class Translator extends BaseTranslator
parent::__construct(null, $selector, $this->options['cache_dir'], $this->options['debug']);
}
/**
* {@inheritdoc}
*/
protected function loadCatalogue($locale)
{
if (null !== $this->options['cache_dir'] && $this->options['debug']) {
$this->loadResources($locale);
}
parent::loadCatalogue($locale);
}
/**
* {@inheritdoc}
*/