Open FranklinYu opened 4 years ago
That's weird, because it is supposed to read the browser language (at least it does that for me):
What language setting does your browser have?
As far as I understand the it, the request is not to use the Accept-Language
header, that is, for
GET /wikiblame.php?lang=en HTTP/1.1
Host: wikipedia.ramselehof.de
Accept-Language: ab
it should return interface in English (according to the lang
query parameter) rather than Abkhazian (denoted by the Accept-Language
header). I like the current version that honors the Accept-Language
header, though. (By the way, in the read_language()
function you define the $acceptLang
variable, but don’t use it. Probably you can just delete that line, as the code seems to work without the isset()
guard.)
I would be happy either way. Even current implementation of Accept-Language
isn’t working. Mine:
Accept-Language: zh-TW,zh;q=0.9,en-US;q=0.8,en;q=0.7,zh-CN;q=0.6
So I would close this issue if Accept-Language
is correctly implemented. According to web standard, even if you cannot correctly handle Chinese variants (this is hard, admittedly), it should fall back to en-US
with 0.8 q number, or at least to en
with 0.7 q number.
The only fallback that is implemented currently is "en" in case autodetection fails, which worked when I tested with zh_TW just now.
Autodetection of Chinese didn't work at all, because the Chinese language files are called zh-hans and zh-hant while WikiBlame tries to open the file "zh". That I tried to fix in d5628d0 , where now it also sets the wiki language to zh-hans/zh-hant. @FranklinYu : I suppose both are supposed to turn into zh.wikipedia.org?
Probably one should really properly handle Accept-Language. But currently I don't have motivation for that :(
Currently when
user_lang
is unspecified, it defaults toab
, even iflang
is specified. Would it be better to defaultuser_lang
tolang
?Example URL: http://wikipedia.ramselehof.de/wikiblame.php?lang=en&article=Ruby_License