From 79f5865aca61414f128ef2ebc077bbb6e192b7cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Solt=C3=A9sz=20Bal=C3=A1zs?= Date: Sun, 15 Feb 2015 16:01:19 +0100 Subject: [PATCH] Review note about setting the translator locale in a controller. --- book/translation.rst | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/book/translation.rst b/book/translation.rst index a5e009d25e9..6131ad5dc7c 100644 --- a/book/translation.rst +++ b/book/translation.rst @@ -425,13 +425,13 @@ via the ``request`` object:: $request->setLocale('en_US'); } - .. note:: - Setting the locale using ``$request->setLocale()`` won't affect rendering - in the same action as the translator reads the request locale during the - kernel.request event, so changing it here would be too late. To manually - change translation locale in the controller use ``$this->get('translator')->setLocale()``. + Setting the locale using the ``$request->setLocale()`` method won't affect + rendering in the same action. The translator locale is set during the + kernel.request event. Either set the locale before the listener is called + (e.g. in a custom listener) or use the ``setLocale()`` method of the + ``translator`` service. .. tip::