Switch language based on user preferences
Opened this issue · 1 comments
jdwillemse commented
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.
- If the user has no locale set (or there's an error reading it) -> DE
- If English is set -> EN
- If multiple are set loop through until DE / EN found
- 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 commented
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