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:
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
+ 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
For reference, I have my LANGUAGE variable set to
\\// Peter - http://www.softwolves.pp.se/
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html