3 ms·
The actual mechanism your User Agent tells the server which languages you are interested in is even more robust [0] ! It is a weighted list of preferences. Th
by rkeene2 7y ago
The actual mechanism your User Agent tells the server which languages you are interested in is even more robust [0] ! It is a weighted list of preferences.
The reasons I've heard from web developers on why they don't use this is because they believe that the user probably never set that up right, and that multiple people could be using the web browser so they need to be able to do the right thing.
What I typically do is select the best matching language from the Accept-Language HTTP header, and then override it with a session-specific value IF one is supplied. Example:
1. https://rkeene.org/projects/6to4/ https://rkeene.org/projects/6to4/
2. https://rkeene.org/projects/6to4/?lang=fr https://rkeene.org/projects/6to4/?lang=fr
You can see PART of the problem here from the web developers perspective. This isn't a negotiation so you have no way to know which languages the server supports. If your preferences aren't totally inclusive you'll get something "wrong". This can be solved by exposing that information (as not done above) and allowing the user to override it (as above).
[0] https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Language https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Ac...