News for hackers. Stuff that matters.
Re:Google Open Source Code Search by rkeene2 on Thursday March 12, 2020 @09:35AM (#22556634)
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/

2. 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/Ac...

There are no comments on this comment yet.