Description
Symfony version(s) affected: 4.3.0-BETA2
Description
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
public function onKernelFinishRequest(FinishRequestEvent $event): void
{
if (null === $parentRequest = $this->requestStack->getParentRequest()) {
$this->setLocale($event->getRequest()->getDefaultLocale());
return;
}
$this->setLocale($parentRequest->getLocale(), $parentRequest->getDefaultLocale());
}
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