Description
If the master request uses a locale different from the default locale and the subrequest does not change the locale through the routing, the locale of the subrequest will be the app default locale instead of the master request locale.
This causes some issues as the translator will not change its locale (it retrieves it only once from the request and is in the container scope) but the routing context will change its _locale
parameter and the intl default locale will change.
But this will also impact any rendering done in the master request after the subrequest as the locale is not reset to the master one.
An easy workaround a would be to set the locale of the master request as default locale for subrequest instead of the app default locale. But this would make the locale in the subrequest inconsistent when enablign ESI.
A way to fix it in a better way could be to trigger an event after the handling of a subrequest to announce the return to the master request. The request object available in this listener should be the master one (which means it cannot be achieved cleanly with a late kernel.response event listener on the subrequest). This listener would then reset the Intl and routing locale with the value from the request (and any other action needed).
@fabpot what do you think about it ?