Skip to content

Commit

Permalink
[FrameworkBundle][Translation][debug mode] refresh cache when resourc…
Browse files Browse the repository at this point in the history
…es is changed.
  • Loading branch information
aitboudad committed Mar 21, 2015
1 parent d1131db commit e36f1a7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,12 @@ public function testLoadRessourcesWithCaching()
$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()
Expand Down
12 changes: 12 additions & 0 deletions src/Symfony/Bundle/FrameworkBundle/Translation/Translator.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,18 @@ public function __construct(ContainerInterface $container, MessageSelector $sele
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}
*/
Expand Down

0 comments on commit e36f1a7

Please sign in to comment.