Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Locale not intercepted #82

Open
lughino opened this issue Jul 15, 2013 · 10 comments
Open

Locale not intercepted #82

lughino opened this issue Jul 15, 2013 · 10 comments

Comments

@lughino
Copy link

lughino commented Jul 15, 2013

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
Copy link
Author

lughino commented Jul 15, 2013

Sorry,
I mistakenly sent twice

@jernejpangersic
Copy link

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

@lunetics
Copy link
Collaborator

@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
Copy link

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
Copy link
Collaborator

Could you try with master version please?

2013/7/18 jernejpangersic [email protected]

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//issues/82#issuecomment-21211144
.

@jernejpangersic
Copy link

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
Copy link
Collaborator

dbu commented Oct 25, 2014

is this still relevant? can we close the issue?

@jossland
Copy link

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

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

@ClementRoupioz
Copy link

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:
- cookie
- session
- browser

@etouraille
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants