Re: [PATCH] http: Add Accept-Language header if possible
- From
Jeff King <peff@peff.net>
- Date
- Jul 9, 2014, 06:18 UTC
- Message-ID
- <20140709061853.GA6731@sigill.intra.peff.net>
- In-Reply-To
- <CAFT+Tg8HZTsbWK2WHHg_q04LY5Vm7cjfNkfHGBEdbKjf1==rKw@mail.gmail.com>
On Wed, Jul 09, 2014 at 02:46:35PM +0900, Yi, EungJun wrote:
Show 6 quoted lines
> 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