All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Krefting <peter@softwolves.pp.se>
To: Yi EungJun <semtlenori@gmail.com>
Cc: git@vger.kernel.org, Yi EungJun <eungjun.yi@navercorp.com>
Subject: Re: [PATCH] http: Add Accept-Language header if possible
Date: Wed, 9 Jul 2014 11:40:05 +0100 (CET)	[thread overview]
Message-ID: <alpine.DEB.2.00.1407091127490.22132@ds9.cixit.se> (raw)
In-Reply-To: <1404834846-11812-1-git-send-email-eungjun.yi@navercorp.com>

Yi EungJun:

> Example:
>  LANGUAGE= -> ""
>  LANGUAGE=ko -> "Accept-Language: ko; q=1.000, *; q=0.001"
>  LANGUAGE=ko:en -> "Accept-Language: ko; q=1.000, en; q=0.999, *; q=0.001"

Avoid adding "q=1.000". It is redundant (the default for any 
unqualified language names is 1.0, and additionally there has 
historically been some buggy servers that failed if it was included.

> +	p1 = getenv("LANGUAGE");

You need a fallback mechanism here to parse all the possible language 
variables. I would use the first one I find of these:

  1. LANGUAGE
  2. LC_ALL
  3. LC_MESSAGES
  4. LANG

Only "LANGUAGE" holds a colon-separated list, but the same code can 
parse all of them, just yielding a single entry for the others.

> +				strbuf_add(buf, p1, p2 - p1);

The tokens are on the form language_COUNTRY.encoding@identifier, whereas 
Accept-Language wants language-COUNTRY, so you need to a) replace "_" 
with "-", and b) chop off anything following a "." or "@".

> +				strbuf_addf(buf, "; q=%.3f", q);
> +				q -= 0.001;

Three decimals seems a bit overkill, but some experimentation might be 
necessary.

> +		strbuf_addstr(buf, "*; q=0.001\r\n");

You should probably also add an explicit "en" here, if none was 
already included. I've seen some servers break horribly if "en" isn't 
included.



For reference, I have my LANGUAGE variable set to 
"sv_SE.utf8:sv:nb_NO.utf8:nb:da_DK.utf8:da:nn_NO.utf8:nn:en_GB.utf8:en_US.utf8:en"

-- 
\\// Peter - http://www.softwolves.pp.se/

  parent reply	other threads:[~2014-07-09 10:40 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-08 15:54 [PATCH] http: Add Accept-Language header if possible Yi EungJun
2014-07-08 21:52 ` Eric Sunshine
     [not found]   ` <CAFT+Tg-6fR9OJ93TT7ww3x=zYHY=Dh5u-7owgQMBK5o_JKLEaA@mail.gmail.com>
     [not found]     ` <CAPig+cQ05pzU9uVBqS8tBHvB8_3qAtgsPYz1sGhpa0W1CVymqA@mail.gmail.com>
2014-07-11 16:35       ` Yi, EungJun
2014-07-09  5:10 ` Jeff King
2014-07-09  5:46   ` Yi, EungJun
2014-07-09  6:18     ` Jeff King
2014-07-09 10:46       ` Peter Krefting
2014-07-10 20:10         ` Jeff King
2014-07-11  9:43           ` Yi, EungJun
2014-07-12 10:11           ` Peter Krefting
2014-07-09 10:40 ` Peter Krefting [this message]
2014-07-11  9:05   ` Yi, EungJun
2015-01-22  7:54 [PATCH v7 1/1] " Junio C Hamano
2015-01-27 15:51 ` [PATCH v8 0/1] " Yi EungJun
2015-01-27 15:51   ` [PATCH] " Yi EungJun
2015-01-27 23:34     ` Junio C Hamano
2015-01-28  6:15       ` Junio C Hamano
2015-01-28 11:59         ` Yi, EungJun

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.DEB.2.00.1407091127490.22132@ds9.cixit.se \
    --to=peter@softwolves.pp.se \
    --cc=eungjun.yi@navercorp.com \
    --cc=git@vger.kernel.org \
    --cc=semtlenori@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.