git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] http: Add Accept-Language header if possible

From
Peter Krefting <peter@softwolves.pp.se>
Date
Jul 9, 2014, 10:46 UTC
Message-ID
<alpine.DEB.2.00.1407091142030.22132@ds9.cixit.se>
In-Reply-To
<20140709061853.GA6731@sigill.intra.peff.net>
Jeff King:
Show 6 quoted lines
> I did some digging, and I think the public API is setlocale with a 
> NULL parameter, like:
>
>  printf("%s\n", setlocale(LC_MESSAGES, NULL));
>
> That still will end up like "en_US.UTF-8", though;
And it only yields the highest-priority language, I think.
> I couldn't find any standard functions for parsing that. It seems 
> like it would be pretty straightforward to do so, though.
RFC 5646 is the current specification on language tags, btw.
>  From my brief reading of rfc2616, that should probably become 
> "en-us", and any time we add "x-y", we may want to add "x" as a 
> fallback (that is certainly true for English; I don't know about 
> other languages with dialects).

Yes, adding the generic fallback is necessary, as "en-US" on the server matches a client's "en", but not vice versa. So if you request "en-US" and "de" and the server only has "en-GB" and "de", you'd get the "de" version.

Debian's website has a nice writeup on the subject: http://www.debian.org/intro/cn#howtoset

-- 
\\// Peter - http://www.softwolves.pp.se/
Previous: Jeff KingNext: Jeff King
Message 6 of 12 in “http: Add Accept-Language header if possible”
  1. http: Add Accept-Language header if possibleYi EungJun, Jul 8, 2014
  2. Eric SunshineJul 8, 2014
  3. Jeff KingJul 9, 2014
  4. Yi, EungJunJul 9, 2014
  5. Jeff KingJul 9, 2014
  6. Peter KreftingJul 9, 2014
  7. Jeff KingJul 10, 2014
  8. Yi, EungJunJul 11, 2014
  9. Peter KreftingJul 12, 2014
  10. Peter KreftingJul 9, 2014
  11. Yi, EungJunJul 11, 2014
  12. Yi, EungJunJul 11, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.