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

Force locale redirects #275

Closed
peterbe opened this issue Dec 3, 2019 · 3 comments · Fixed by #11518
Closed

Force locale redirects #275

peterbe opened this issue Dec 3, 2019 · 3 comments · Fixed by #11518
Labels
🧑‍🤝‍🧑 community contributions by our wonderful community 🐌 idle Issues and PRs without recent activity. Flagged for maintainer follow-up. idle localization i18n & l10n p3 We don't have visibility when this will be addressed. 🚉 platform keeping the platform healthy redirects all things related to redirecting

Comments

@peterbe
Copy link
Contributor

peterbe commented Dec 3, 2019

A lot of people prefer a different locale (of en-US) than the one they click on. One very common example is a non-English user, who lives in France for example, who googles for something and since Google prefers localized content she's presented with a link to https://developer.mozilla.org/fr/docs/Apprendre/Commencer_avec_le_web which she clicks. Upon arrival, she realizes she prefers the English version so she has to click the language switcher to go over to https://developer.mozilla.org/en-US/docs/Learn/Getting_started_with_the_web

She could have installed MDN Language Redirector but that's a pain.

@peterbe
Copy link
Contributor Author

peterbe commented Dec 3, 2019

It would be much more convenient to ask the user, after they changed locale, "Do you prefer this language?" and if they say yes, put a thing into localStorage and now we can always do a check like this:

class App extends Component {
    componentDidMount() {
        var preferred = localStorage.getItem('preferred-locale')
        var current = this.getCurrentLocale()
        if (preferred && preferred !== current) {
            this.startReactRouterRedirectTo(preferred).then(() => {
               // alternatively use sessionStorage depend on how we do or don't use client-side navigation
               this.setState({redirectedFrom: current})
               
            })
        }
    }
}

This way we keep our server code much simpler and users won't have to register and sign in and besides a check like this doesn't require network, unlike a fetch('/api/v1/whoami') which is much much slower.

@peterbe
Copy link
Contributor Author

peterbe commented Dec 3, 2019

Typical example: mdn/kuma#6166

@peterbe peterbe changed the title Force redirects Force locale redirects Dec 3, 2019
@peterbe peterbe added the redirects all things related to redirecting label Oct 1, 2020
@peterbe
Copy link
Contributor Author

peterbe commented Oct 1, 2020

@escattone Would it be at all feasible to make our Lambda@Edge depend on a cookie? I know (with 90% certainty) that technically it's possible to have CloudFront take the cookie into account. But it might get messy.

We could implement something fairly easily, in the client code. If you arrive on a non-en-US page, you have access to localStorage and you have access to doc.translation_of so you could kick off a piece of code that does an in-page redirect based on the users' localStorage. Historically, we've seen a lot of people complain about this in Kuma but, at one point, we said this could be done "server-side" as a cool feature to justify signing in. Ie. instead of relying on localStorage you rely on /api/v1/whoami which tells the document that this user prefers some other locale.

At this point, it's more of a "product" decision rather than a matter of regular Yari redirect problems.

@schalkneethling schalkneethling added the 🚉 platform keeping the platform healthy label Nov 2, 2021
@github-actions github-actions bot added the 🐌 idle Issues and PRs without recent activity. Flagged for maintainer follow-up. label Dec 9, 2021
@schalkneethling schalkneethling added the 🧑‍🤝‍🧑 community contributions by our wonderful community label Apr 15, 2022
@caugner caugner added p3 We don't have visibility when this will be addressed. localization i18n & l10n labels Nov 30, 2022
@github-actions github-actions bot added the idle label Dec 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🧑‍🤝‍🧑 community contributions by our wonderful community 🐌 idle Issues and PRs without recent activity. Flagged for maintainer follow-up. idle localization i18n & l10n p3 We don't have visibility when this will be addressed. 🚉 platform keeping the platform healthy redirects all things related to redirecting
Projects
Development

Successfully merging a pull request may close this issue.

3 participants