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

[#5080] Use browser locale #5354

Closed
wants to merge 5 commits into from
Closed

Conversation

lizconlan
Copy link

Relevant issue(s)

#5080

What does this do?

A quick spike exploring what might be involved in accepting the user's language preferences from their browser settings (only relevant to multi language sites)

Why was this needed?

We currently give more weight than intended to the default locale when falling back to it without a param value (when the site is configured not to have the default locale in the URL - which is the most common choice).

Implementation notes

  • No tests as I was just seeing if it was possible
  • Might not work as expected when refusing cookies or running in incognito mode
  • Bonus feature - we may have to patch FastGettext to get "nl" from the browser to be matched to "nl_BE"

(In other words, I may have justified nobody working on this as it's more trouble than it's worth!)

Notes to reviewer

The unexpected finding on collect_locales (155799e) might be useful though - although maybe it could go in AlaveteliLocalization.set_locales? - if there is ever a reported problem with the language switcher working incorrectly after a locale change.

Preparation for trying to conditionally check the user's language
preference from their browser settings first before accepting the
locale from params as that is never nil when the default locale is not
included in the URL (which is true for most of our sites)
This might not work as expected from an incognito session. More testing
needed!
Otherwise if the session resets, the data is lost. Also we check cookies
but I can't see where we set it.
Otherwise the data in @locales can get out of sync and the language
switcher can be rendered incorrectly
Really confusing otherwise as we always think of the locale from params
as the authortative setting
browser_locale =
if AlaveteliConfiguration.use_default_browser_language
request.env['HTTP_ACCEPT_LANGUAGE']
else

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redundant else-clause.

@garethrees
Copy link
Member

Closed to reduce overwhelm of high WIP. Can reopen in the future if necessary.

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

Successfully merging this pull request may close these issues.

3 participants