Skip to content

Commit 3b136c8

Browse files
solazsweaverryan
authored andcommitted
Update translation.rst
Clarify that changing the locale in the controller would not affect template rendering as the translator reads the request locale during the kernel.request event.
1 parent e5c28c8 commit 3b136c8

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

book/translation.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,14 @@ via the ``request`` object::
424424

425425
$request->setLocale('en_US');
426426
}
427+
428+
429+
.. note::
430+
431+
Setting the locale using ``$request->setLocale()`` won't affect rendering
432+
in the same action as the translator reads the request locale during the
433+
kernel.request event, so changing it here would be too late. To manually
434+
change translation locale in the controller use ``$this->get('translator')->setLocale()``.
427435

428436
.. tip::
429437

0 commit comments

Comments
 (0)