8000 [FrameworkBundle][Translation][debug mode] refresh cache when resourc… · symfony/symfony@e36f1a7 · GitHub
[go: up one dir, main page]

Skip to content

Commit e36f1a7

Browse files
committed
[FrameworkBundle][Translation][debug mode] refresh cache when resources is changed.
1 parent d1131db commit e36f1a7

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,12 @@ public function testLoadRessourcesWithCaching()
122122
$translator->setLocale('fr');
123123

124124
$this->assertEquals('répertoire', $translator->trans('folder'));
125+
126+
// refresh cache when resources is changed in debug mode.
127+
$translator = $this->getTranslator($loader, array('cache_dir' => $this->tmpDir, 'debug' => true), array(), 'yml');
128+
$translator->setLocale('fr');
129+
130+
$this->assertEquals('folder', $translator->trans('folder'));
125131
}
126132

127133
public function testLoadRessourcesWithoutCaching()

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,18 @@ public function __construct(ContainerInterface $container, MessageSelector $sele
6363
parent::__construct(null, $selector, $this->options['cache_dir'], $this->options['debug']);
6464
}
6565

66+
/**
67+
* {@inheritdoc}
68+
*/
69+
protected function loadCatalogue($locale)
70+
{
71+
if (null !== $this->options['cache_dir'] && $this->options['debug']) {
72+
$this->loadResources($locale);
73+
}
74+
75+
parent::loadCatalogue($locale);
76+
}
77+
6678
/**
6779
* {@inheritdoc}
6880
*/

0 commit comments

Comments
 (0)
0