Page MenuHomePhabricator

Wiki interface ignores $wgLanguageCode when ULS is activated (picks first exact match from browser's "Accept-Language")
Open, Needs TriagePublic

Description

Hello,

I'm using ULS 2017.01 and MW 1.28.1.
The default language ($wgLanguageCode) on my wiki is French but when I browse to the wiki with a clean browser session, the wiki interface is displayed in English instead of French.
If I disable ULS, the wiki is correctly displayed in French.

Event Timeline

Nikerabbit subscribed.

It sounds like your browser is configured to request pages in English, thus it functions as expected.

Since it is so often misconfigured to be in English, someone could consider hacking the code to ignore English from Accept-Language header. I don't recommend doing that though.

Here is my Accept-Language header: fr-FR,en;q=0.5.
Since French is listed first, shouldn't it be picked instead of English?

I tried tweaking it to fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3 and now the wiki is indeed displayed in French.

The UniversalLanguageSelectorHooks::getDefaultLanguage implementation is less than ideal in this regard. It takes first exact match, failing that, it strips the country code away and tries again. Perhaps it should be more aggressive at that stripping.

Aklapper renamed this task from Wiki interface defaults to English instead of $wgLanguageCode when ULS is activated to Wiki interface ignores $wgLanguageCode when ULS is activated (picks first exact match from browser's "Accept-Language").Apr 19 2017, 1:45 PM