JMSI18nRoutingBundle
JMSI18nRoutingBundle copied to clipboard
Default Locale problem
Hi,
Why is it the default locale always goes to "en" even though it is in the list. Any ideas?
Here's the config.
jms_i18n_routing: default_locale: ie locales: [pt,dk,ie] strategy: prefix
Thanks in advance.
+1
+1
+1
my problem was in my Listener that changes locale in session, for emulation previous behavior
Unexpected behavior of DefaultLocaleResolver
. If no locale specified in session, cookie or request then default locale is ignored and locale will be choosed from intersection of locales list in Http-Accept-Language and enabled locales for bundle…
You can redefine single param in config and create modified locale resolver (example: https://gist.github.com/dmishh/5388499)
parameters:
jms_i18n_routing.locale_resolver.class: Some\Your\Namespace\DefaultLocaleResolver
@dmishh If this is unexpected behavior shouldn't it be fixed? /cc @schmittjoh
Hey guys, we ran into something similar and here's how we handled it. Basically, we discovered that Symfony's Request component references a hardcoded defaulted value of "en" when setting the locale to the route parameters. $request->getLocale()
would always resolve to fetching the defaultLocale value which was a hardcoded string of "en".
Changing the locale listener allowed for us to make use of the kernel's default_locale parameter.
https://gist.github.com/passion4code/9516424