FlominatorTM / wikiblame

http://wikipedia.ramselehof.de/wikiblame.php
GNU General Public License v3.0
54 stars 13 forks source link

Default UI language to Wikipedia language #28

Open FranklinYu opened 4 years ago

FranklinYu commented 4 years ago

Currently when user_lang is unspecified, it defaults to ab, even if lang is specified. Would it be better to default user_lang to lang?

Example URL: http://wikipedia.ramselehof.de/wikiblame.php?lang=en&article=Ruby_License

FlominatorTM commented 4 years ago

That's weird, because it is supposed to read the browser language (at least it does that for me):

https://github.com/FlominatorTM/wikiblame/blob/93038c5cd940a08ba3f5d8774e9bd764fb7d9297/wikiblame.php#L30

https://github.com/FlominatorTM/wikiblame/blob/93038c5cd940a08ba3f5d8774e9bd764fb7d9297/shared_inc/language.inc.php#L47

What language setting does your browser have?

tacsipacsi commented 4 years ago

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.)

FranklinYu commented 4 years ago

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.

FlominatorTM commented 4 years ago

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 :(