JMSI18nRoutingBundle icon indicating copy to clipboard operation
JMSI18nRoutingBundle copied to clipboard

Default Locale problem

Open rifeman2007 opened this issue 12 years ago • 7 comments

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.

rifeman2007 avatar Oct 04 '12 18:10 rifeman2007

+1

webspin avatar Oct 24 '12 23:10 webspin

+1

fadisdh avatar Mar 02 '13 20:03 fadisdh

+1

maguramarkian avatar Mar 29 '13 10:03 maguramarkian

my problem was in my Listener that changes locale in session, for emulation previous behavior

maguramarkian avatar Apr 09 '13 09:04 maguramarkian

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 avatar Apr 15 '13 14:04 dmishh

@dmishh If this is unexpected behavior shouldn't it be fixed? /cc @schmittjoh

stefantalen avatar Nov 05 '13 12:11 stefantalen

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

passion4code avatar Mar 12 '14 21:03 passion4code