You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current BETA2 has an issue with the TranslationDataCollector in combination with the LocaleAwareListener. I'm running a page with _locale prefixed routes and all works fine, but the profiler shows an incorrect locale. It just shows my default en.
For me the LocaleAwareListener is to blame for this. It's subscribing to onKernelRequest and onKernelFinishRequest and therefore setting the locale twice.
The first time all wents fine, but on the finish part
we don't have a $parentRequest and setLocale() is called with the default value, which is then injected into the Translator and lately collected by the TranslationDataCollector.
How to reproduce
Setup a simple app with 2 locales and check the profiler.
Possible Solution
No clue what part is the broken one. Could also be the collector running too late.
Additional context
See attached screenshots. Locale shows "en" while it's using German messages. The intl part is also set correctly.
Cheers
Matthias
The text was updated successfully, but these errors were encountered:
… (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
Symfony version(s) affected: 4.3.0-BETA2
Description
The current BETA2 has an issue with the
TranslationDataCollector
in combination with theLocaleAwareListener
. I'm running a page with_locale
prefixed routes and all works fine, but the profiler shows an incorrect locale. It just shows my defaulten
.For me the
LocaleAwareListener
is to blame for this. It's subscribing toonKernelRequest
andonKernelFinishRequest
and therefore setting the locale twice.The first time all wents fine, but on the finish part
we don't have a $parentRequest and
setLocale()
is called with the default value, which is then injected into the Translator and lately collected by the TranslationDataCollector.How to reproduce
Setup a simple app with 2 locales and check the profiler.
Possible Solution
No clue what part is the broken one. Could also be the collector running too late.
Additional context
See attached screenshots. Locale shows "en" while it's using German messages. The intl part is also set correctly.
Cheers
Matthias
The text was updated successfully, but these errors were encountered: