Re: [PATCH] http: Add Accept-Language header if possible
From: Jeff King <hidden>
Date: 2016-06-15 23:01:50
On Wed, Jul 09, 2014 at 02:46:35PM +0900, Yi, EungJun wrote:
I agree with you. In fact, I tried to get user's preferred language in the same way as gettext. It has guess_category_value() to do that and the function is good enough because it considers $LANGUAGE, $LC_ALL, $LANG, and also system-dependent preferences. But the function does not seem a public API and I don't know how can I use the function in Git. So I chose to use $LANGUAGE only.
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; I couldn't find any
standard functions for parsing that. It seems like it would be pretty
straightforward to do so, though.
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). -Peff