Skip to content

Commit af46923

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 9a53d1e commit af46923

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
@@ -430,6 +430,14 @@ via the ``request`` object::
430430

431431
$request->setLocale('en_US');
432432
}
433+
434+
435+
.. note::
436+
437+
Setting the locale using ``$request->setLocale()`` won't affect rendering
438+
in the same action as the translator reads the request locale during the
439+
kernel.request event, so changing it here would be too late. To manually
440+
change translation locale in the controller use ``$this->get('translator')->setLocale()``.
433441

434442
.. tip::
435443

0 commit comments

Comments
 (0)