Page MenuHomePhabricator

The language code 'no' is ignored in Accept-Language HTTP header
Open, Needs TriagePublicBUG REPORT

Description

Firefox supports as language settings Norwegian with the language code no. It also supports Bokmål with the language code nb and Nynorsk with the language code nn. When you set as preferred language no as first language and an other language code like nl as second language you get the HTTP header

Accept-Language: no,nl;q=0.5

According to https://www.iana.org/assignments/language-subtag-registry no (Norwegian) is a macro language with the languages nb (Norwegian Bokmål) and nn (Norwegian Nynorsk).

MediaWiki normally substitutes the language code no by nb.

ULS does not support the fallback from no to nb for the Accept-Language HTTP header and ignores no:

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

returns

<!DOCTYPE html>
<html class="client-nojs" lang="nl" dir="ltr">

Expected result is lang="nb" or lang="no".

Since rMW4cc7dea1d52d the MediaWiki-Installer has the same problem:

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

returns

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

The language code bh has the same problem like no.

This bug is related to T183295.

Event Timeline

Change 413136 had a related patch set uploaded (by Fomafix; owner: Fomafix):
[mediawiki/extensions/UniversalLanguageSelector@master] Support extra languages in Accept-Language HTTP header

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

I doubt "The language code bh has the same problem like no." is correct, since bh is a collection languages' code for Bihari languages.

Firefox supports bh but does not support bho. Mediawiki selects on uselang=bh the language code bho because of the mapping in DefaultSettings.php:

$wgExtraLanguageCodes = [
	'bh' => 'bho', // Bihari language family
	'no' => 'nb', // Norwegian language family
	'simple' => 'en', // Simple English
];

In the Accept-Language HTTP header the language code bh is ignored because of the same reason as for no.

Hmm. In https://www.iana.org/assignments/language-subtag-registry/language-subtag-registry is no a macrolanguage and bh a collection:

%%
Type: language
Subtag: no
Description: Norwegian
Added: 2005-10-16
Suppress-Script: Latn
Scope: macrolanguage
%%
[...]
%%
Type: language
Subtag: bh
Description: Bihari languages
Added: 2005-10-16
Scope: collection
%%
Fomafix changed the subtype of this task from "Task" to "Bug Report".Feb 28 2019, 7:50 AM

Removing task assignee due to inactivity, as this open task has been assigned to the same person for more than two years (see the emails sent to the task assignee on Oct27 and Nov23). Please assign this task to yourself again if you still realistically [plan to] work on this task - it would be welcome.
(See https://www.mediawiki.org/wiki/Bug_management/Assignee_cleanup for tips how to best manage your individual work in Phabricator.)

Change 413136 abandoned by Nikerabbit:

[mediawiki/extensions/UniversalLanguageSelector@master] Support extra languages in Accept-Language HTTP header

Reason:

Issue is real, but this is not a suitable fix.

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