Here in Switzerland, I am so tired of websites offering German localization by default. We don’t speak German in Geneva.
Here in Switzerland, I am so tired of websites offering German localization by default. We don’t speak German in Geneva.
1. Check if there is a language cookie set previously 2. If no cookie, check if the Accept-Language is present and contains one of the supported locales 3. If no Accept-Language matches, use the fallback application language
Not that hard to implement, except perhaps parsing the Accept-Language preferences with their quality value can be cumbersome.
To answer the question, yes, normally you would have some kind of manual switcher that sets the cookie. Please don’t use flags for this, because flags indicate countries, not languages. Don’t make a Russian-speaking Ukrainian seek out the Russian flag, and don’t make an English-speaking Irish person seek out the Union Flag.
Yes, why make things easy. :-)
Controversial opinion: Flags are great as a visual aid, shorthand, look neat, and give a better UX for 90+% of users, even if it hurts some linguists' and nationalists' feelings.
(Bonus point for fr_CA with the CA-QC flag)
Just don't use flags, man. It's ridiculous that this is even still a discussion.
If you use flags I would still recommend putting the language name in the language next to it, for example the French flag next to 'Français'.
What flags to you suggest people use for Cantonese, Tamil, Arabic and Xhosa?
Why use the Union flag for English? If the language is en-US surely an American flag would be more accurate? You can then use the British flag for en-GB. However, if you offer Welsh you would use the Welsh flag (and presumably the Scottish one for Scottish Gaelic, although I cannot recall ever seeing that) so it would surely be more consistent to use the English flag for British? Even for or generic English?
Many web frameworks provide a tool for parsing these for you. If yours doesn't (or you're not using one) you may be able to find a package that does. Some will also do the matching for you, so you can pass it a list of languages you can support alongside the Accept-Language string and it will pick the best option that's found in both.
For example, here's the documentation for such a method in the excellent Nette PHP framework that I've been using where I can lately: https://doc.nette.org/en/http/request#toc-detectlanguage
But I've also used this stand-alone package: https://packagist.org/packages/willdurand/negotiation