Page MenuHomePhabricator

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

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

Fomafix created this task.Feb 21 2018, 11:18 AM
Restricted Application added subscribers: jeblad, jhsoby, Aklapper. · View Herald TranscriptFeb 21 2018, 11:18 AM

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

Fomafix updated the task description. (Show Details)Feb 22 2018, 3:02 PM

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 updated the task description. (Show Details)Feb 22 2018, 4:04 PM
Fomafix updated the task description. (Show Details)
Fomafix changed the subtype of this task from "Task" to "Bug Report".Feb 28 2019, 7:50 AM