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 0bf50cf

Browse filesBrowse files
bug #31815 [Translator] Collect locale details earlier in the process (pierredup)
This PR was merged into the 4.3 branch. Discussion ---------- [Translator] Collect locale details earlier in the process | Q | A | ------------- | --- | Branch? | 4.3 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #31600 | License | MIT | Doc PR | N/A The [LocaleAwareListener](https://github.com/symfony/symfony/blob/4.3/src/Symfony/Component/HttpKernel/EventListener/LocaleListener.php) class reverts the locale back to the default locale when the request has finished. But the `TranslationDataCollector` only collects the locale in `lateCollect`, which only happens when the kernel terminates. This means the locale is reverted back to the default by the time the collector runs. The PR moves the `locale` and `fallback_locales` from `lateCollect` to `collect`, so that the information can be captured earlier, before the `LocaleAwareListener` is run. Commits ------- 5c394ee Collect locale details earlier in the process in TranslationDataCollector
2 parents d8224b8 + 5c394ee commit 0bf50cf
Copy full SHA for 0bf50cf

File tree

Expand file treeCollapse file tree

1 file changed

+3
-4
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+3
-4
lines changed

‎src/Symfony/Component/Translation/DataCollector/TranslationDataCollector.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Translation/DataCollector/TranslationDataCollector.php
+3-4Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,9 @@ public function lateCollect()
3636
{
3737
$messages = $this->sanitizeCollectedMessages($this->translator->getCollectedMessages());
3838

39-
$this->data = $this->computeCount($messages);
39+
$this->data += $this->computeCount($messages);
4040
$this->data['messages'] = $messages;
4141

42-
$this->data['locale'] = $this->translator->getLocale();
43-
$this->data['fallback_locales'] = $this->translator->getFallbackLocales();
44-
4542
$this->data = $this->cloneVar($this->data);
4643
}
4744

@@ -50,6 +47,8 @@ public function lateCollect()
5047
*/
5148
public function collect(Request $request, Response $response, \Exception $exception = null)
5249
{
50+
$this->data['locale'] = $this->translator->getLocale();
51+
$this->data['fallback_locales'] = $this->translator->getFallbackLocales();
5352
}
5453

5554
/**

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.