From 03de10f52711f9c15d7507db76d756f9ce257af4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Niedzielski?= Date: Wed, 20 Sep 2017 09:56:46 +0200 Subject: [PATCH 1/4] Add note about LocaleListener LocaleListener uses information provided by Request object. Setting it after LocaleListener read the object results in no effect. --- translation/locale.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/translation/locale.rst b/translation/locale.rst index 89c94b28fd0..2f190ebd95f 100644 --- a/translation/locale.rst +++ b/translation/locale.rst @@ -25,6 +25,12 @@ it:: // some logic to determine the $locale $request->setLocale($locale); } +.. note:: + + Using a listener like this requires that it is called **before** + LocaleListener attempts to access it. In Symfony Framework it is called + with priority 8 by default. You will need to set your event listener + with a higher one if you want this to work. Read :doc:`/session/locale_sticky_session` for more information on making the user's locale "sticky" to their session. From 52681f45597bdb0d68fd33048ee83535816ad530 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Niedzielski?= Date: Wed, 20 Sep 2017 17:27:17 +0200 Subject: [PATCH 2/4] Fix missing blank line --- translation/locale.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/translation/locale.rst b/translation/locale.rst index 2f190ebd95f..3c6e192aebf 100644 --- a/translation/locale.rst +++ b/translation/locale.rst @@ -25,6 +25,7 @@ it:: // some logic to determine the $locale $request->setLocale($locale); } + .. note:: Using a listener like this requires that it is called **before** From 1492f3e4f65ca1ee7f2a664a9b047f4f280f428d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Niedzielski?= Date: Wed, 27 Sep 2017 15:02:05 +0200 Subject: [PATCH 3/4] Remove information about default priority --- translation/locale.rst | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/translation/locale.rst b/translation/locale.rst index 3c6e192aebf..ee6c60aa812 100644 --- a/translation/locale.rst +++ b/translation/locale.rst @@ -29,9 +29,8 @@ it:: .. note:: Using a listener like this requires that it is called **before** - LocaleListener attempts to access it. In Symfony Framework it is called - with priority 8 by default. You will need to set your event listener - with a higher one if you want this to work. + LocaleListener attempts to access it. You will need to set your event listener + with a higher priority if you want this to work. Read :doc:`/session/locale_sticky_session` for more information on making the user's locale "sticky" to their session. From 531909d8fad045881c517cb7b8cce9eb8d161a7b Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Thu, 4 Jan 2018 16:03:10 +0100 Subject: [PATCH 4/4] Reword --- translation/locale.rst | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/translation/locale.rst b/translation/locale.rst index ee6c60aa812..97b86764cbf 100644 --- a/translation/locale.rst +++ b/translation/locale.rst @@ -28,9 +28,10 @@ it:: .. note:: - Using a listener like this requires that it is called **before** - LocaleListener attempts to access it. You will need to set your event listener - with a higher priority if you want this to work. + The custom listener must be called **before** ``LocaleListener``, which + initializes the locale based on the current request. To do so, set your + listener priority to a higher value than ``LocaleListener`` priority (which + you can obtain running the ``debug:event kernel.request`` command). Read :doc:`/session/locale_sticky_session` for more information on making the user's locale "sticky" to their session.