Fixed issue #6932 - Inconsistent locale handling in subrequests

The fix consists in passing the locale in the controller reference,
by making the controller twig function aware of the current context.
There are a few additional checks for the request scope, in order
not to break compatibility when using the console.

See #6932 for a description of the issue