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

Switch language based on user preferences #47

Open
jdwillemse opened this issue Jan 10, 2024 · 1 comment
Open

Switch language based on user preferences #47

jdwillemse opened this issue Jan 10, 2024 · 1 comment

Comments

@jdwillemse
Copy link

jdwillemse commented Jan 10, 2024

It is possible to serve the webpage in the user's preferred language without them having to manually toggle the language. Let's do that.

Suggestion

When the user lands their browser language preferences are checked and the matching language is served. I would suggest the following flow. Open to discussion.

  1. If the user has no locale set (or there's an error reading it) -> DE
  2. If English is set -> EN
  3. If multiple are set loop through until DE / EN found
  4. If a locale is set but nor DE or EN -> EN

Currently

The user lands on German landing page by default and manually has to switch to English if they do not g=speak German

@SThomasP
Copy link
Contributor

SThomasP commented Feb 5, 2024

https://nanmu.me/en/posts/2020/hugo-i18n-automatic-language-redirection/
https://developer.mozilla.org/en-US/docs/Web/API/Navigator/languages

I'll create a PR when I'm done, but I'm actively working on it, It'll need a small amount of js, but I'll add a noscript alternative as well

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 a pull request may close this issue.

2 participants