Page MenuHomePhabricator

Installer should ignore untranslated language codes from Accept-Language
Closed, ResolvedPublic

Description

Currently the installer selects the first language code from the Accept-Language HTTP header that is known to MediaWiki even when it is not translated. For example the language code aa (Afar) is known to MediaWiki but it has no translation and therefor the user interface language is English.

On the HTTP header

Accept-Language: aa,nl;q=0.5

the installer selects lang="aa" and shows English user interface. It would be better to ignore the untranslated language code aa and use the next language code that is translated, here nl.

Steps to reproduce:

$ curl -L -H 'Accept-Language: aa,nl;q=0.5' 'http://localhost/mediawiki/mw-config/' 2> /dev/null | head -2

current result:

<!DOCTYPE html>
<html dir="ltr" lang="aa">

expected result:

<!DOCTYPE html>
<html dir="ltr" lang="nl">

The UniversalLanguageSelector has a implementation that support this case:

$ curl -L -H 'Accept-Language: aa,nl;q=0.5' 'http://localhost/mediawiki/' 2> /dev/null | head -2
<!DOCTYPE html>
<html class="client-nojs" lang="nl" dir="ltr">

The two implementations should be merged and refactored to a single place in core.

Related tasks: T187866 and T183295

Event Timeline

Fomafix created this task.Feb 22 2018, 6:53 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptFeb 22 2018, 6:53 PM

Change 414513 had a related patch set uploaded (by Fomafix; owner: Fomafix):
[mediawiki/core@master] [WIP] Ignore untranslated language codes from Accept-Languages

https://gerrit.wikimedia.org/r/414513

Change 440751 had a related patch set uploaded (by Fomafix; owner: Nikerabbit):
[mediawiki/core@master] Only use languages with localisation in the installer

https://gerrit.wikimedia.org/r/440751

Change 414513 abandoned by Fomafix:
[WIP] Ignore untranslated language codes from Accept-Languages

Reason:
Superseded by https://gerrit.wikimedia.org/r/440751

https://gerrit.wikimedia.org/r/414513

Change 440751 merged by jenkins-bot:
[mediawiki/core@master] Only use languages with localisation in the installer

https://gerrit.wikimedia.org/r/440751

Fomafix closed this task as Resolved.Jun 22 2018, 2:59 PM
Fomafix assigned this task to Nikerabbit.
Fomafix removed a project: Patch-For-Review.