lunetics-org / LocaleBundle

Locale Bundle for symfony
MIT License
186 stars 76 forks source link

Locale not intercepted #82

Open lughino opened 11 years ago

lughino commented 11 years ago

Hello, I have a problem like this: I have the routes set this way:

index_not_localized:
    path:   /
    defaults:  { _controller: "AcmeSiteBundle:Default:index", _locale: %locale% }

acme_site:
    resource: "@AcmeSiteBundle/Controller/"
    type:     annotation
    prefix:   /{_locale}/
    defaults:  { _locale: %locale% }
    requirements:
        _locale:  en|it

if I go to www.example.com is set to the default local and not that of the user. I have configured this way:

guessing_order:
    - query
    - router
    - session
    - cookie
    - browser

But if imposed as this configuration:

guessing_order:
    - session
    - cookie
    - browser
    - query
    - router

even if switch to another language does not change the value of the session and cookies. Is there a problem, or I'm wrong configuration? How can I get what I want? thanks

lughino commented 11 years ago

Sorry, I mistakenly sent twice

jernejpangersic commented 11 years ago

I have a similar issue...Is it possible that the guessers aren't working?

lunetics commented 11 years ago

@Lughino you have to decide if you use stateful or stateless. If a language is found, the guesser exits. So, if query is used at first and the query is guessed via the query guesser, no cookie / session will be set.

Which version of symfony are you using and which version / tag of the localebundle

jernejpangersic commented 11 years ago

I hope it's OK if I post here aswell.

lunetics_locale:
  allowed_locales:
    - en
    - sl
    - fr
  cookie:
    set_on_change: true
  guessing_order:
      - browser
      - session
      - cookie
      - router
      - query

From my composer.json:

"lunetics/locale-bundle": "2.2.*"
"symfony/symfony": "2.3.*",
lunetics commented 11 years ago

Could you try with master version please?

2013/7/18 jernejpangersic notifications@github.com

I hope it's OK if I post here aswell.

lunetics_locale: allowed_locales:

  • en
  • sl
  • fr cookie: set_on_change: true guessing_order:
    • browser
    • session
    • cookie
    • router
    • query

From my composer.json:

"lunetics/locale-bundle": "2.2." "symfony/symfony": "2.3.",

— Reply to this email directly or view it on GitHubhttps://github.com/lunetics/LocaleBundle/issues/82#issuecomment-21211144 .

jernejpangersic commented 11 years ago

EDIT: I added "lunetics/locale-bundle": "dev-master", to composer.json

Unfortunately it still doesn't get the locale from user's browser. I'm trying to get the locale from the browser, without using any {_locale} variables in the URL. Is this possible? Even with using the built in language switcher, it doesn't change the cookie.

dbu commented 9 years ago

is this still relevant? can we close the issue?

jossland commented 9 years ago

I have the same problem. It doesn't write the cookie.

"symfony/symfony": "2.5.", "lunetics/locale-bundle": "2.3."

ClementRoupioz commented 9 years ago

Same problem. If I switch page, cookie are reset :/ With that {{ locale_switcher() }}, the {{ app.request.locale }} became my selection. But at the page switch, it's back to "normal".

And I have the cookie on change and Cookie/Session/browser as order cookie:
set_on_change: true guessing_order:

etouraille commented 8 years ago

I have the same problem as you, I investigated in the code, and If i do some echo in the code, the cookie change it value when i use the local_switcher, but not if i dump nothing