Page MenuHomePhabricator

Wikibase entity view does not map nonstandard language codes to standard ones for HTML
Open, Needs TriagePublic

Description

For example, in https://www.wikidata.org/wiki/Q42?uselang=de-formal:

<div id="mw-content-text" lang="de-x-formal" dir="ltr" class="mw-content-ltr"><div id="wb-item-Q42" class="wikibase-entityview wb-item" lang="de-formal" dir="ltr">

The lang attribute should have the value de-x-formal, not de-formal. de-formal is the MediaWiki language code, de-x-formal the BCP 47 standard language code. A mapping from the former to the latter is available via the \LanguageCode class (server-side) and the api=query&meta=languageinfo API (client-side).

Note that MediaWiki emits the correct language code:

<html class="client-nojs" lang="de-x-formal" dir="ltr">