Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e99c09e

Browse filesBrowse files
committed
minor #14011 [Translation][debug mode] refresh cache when resources is changed. (aitboudad)
This PR was merged into the 2.7 branch. Discussion ---------- [Translation][debug mode] refresh cache when resources is changed. | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Fixed tickets | #13897 | Tests pass? | yes | License | MIT Commits ------- e36f1a7 [FrameworkBundle][Translation][debug mode] refresh cache when resources is changed.
2 parents 707f3d3 + e36f1a7 commit e99c09e
Copy full SHA for e99c09e

File tree

2 files changed

+18
-0
lines changed
Filter options

2 files changed

+18
-0
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/Translation/TranslatorTest.php
+6Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Translation/Translator.php
+12Lines 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)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.