8000 bug #37449 [Translation] Fix caching of parent locales file in transl… · symfony/symfony@78e6fc4 · GitHub
[go: up one dir, main page]

Skip to content

Commit 78e6fc4

bug #37449 [Translation] Fix caching of parent locales file in translator (jvasseur)
This PR was merged into the 4.4 branch. Discussion ---------- [Translation] Fix caching of parent locales file in translator | Q | A | ------------- | --- | Branch? | 4.4 (this is the lowest maintained branch with this code) | Bug fix? | yes | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tickets | | License | MIT | Doc PR | The `parentLocales` property was probably meant as a cache for the content of the `parents.json` file but instead the content is stored in a local variable and the property stays `null`. This means the file is read on each call to `computeFallbackLocales`. This PR update the code to what was probably meant to be. (Ref #28070) Commits ------- 02c9ac6 Fix caching of parent locales file in translator
2 parents f194602 + 02c9ac6 commit 78e6fc4

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/Symfony/Component/Translation/Translator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ private function loadFallbackCatalogues(string $locale): void
460460
protected function computeFallbackLocales($locale)
461461
{
462462
if (null === $this->parentLocales) {
463-
$parentLocales = json_decode(file_get_contents(__DIR__.'/Resources/data/parents.json'), true);
463+
$this->parentLocales = json_decode(file_get_contents(__DIR__.'/Resources/data/parents.json'), true);
464464
}
465465

466466
$locales = [];
@@ -473,7 +473,7 @@ protected function computeFallbackLocales($locale)
473473
}
474474

475475
while ($locale) {
476-
$parent = $parentLocales[$locale] ?? null;
476+
$parent = $this->parentLocales[$locale] ?? null;
477477

478478
if ($parent) {
479479
$locale = 'root' !== $parent ? $parent : null;

0 commit comments

Comments
 (0)
0