Page MenuHomePhabricator

Wikibase classic termbox (entity terms view) drops last user babel language if interface language is not in babel
Closed, ResolvedPublic

Description

As a Wikidata editor, I want to see the termbox in all the languages that I’ve declared in my babel, as well as in the user interface language (if that’s not already in the babel).

Problem:
Since 2014 (I38cc93a9db, rEWBAf1f23c217189: Integrated fingerprintgroupview into entityview), Wikibase has had code similar to this determining the languages for the termbox (and possibly other places, not sure what else uses them):

wb.getUserLanguages()
var userLanguages = mw.config.get( 'wbUserSpecifiedLanguages', [] ),
	isUlsDefined = mw.uls && $.uls && $.uls.data,
	languages;

if ( !userLanguages.length && isUlsDefined ) {
	languages = mw.uls.getFrequentLanguageList().slice( 1, 4 );
} else {
	languages = userLanguages.slice();
	languages.splice( userLanguages.indexOf( mw.config.get( 'wgUserLanguage' ) ), 1 );
}

languages = filterInvalidTermsLanguages( languages );
languages.unshift( mw.config.get( 'wgUserLanguage' ) );

If the wbUserSpecifiedLanguages don’t include the wgUserLanguage, then userLanguages.indexOf( mw.config.get( 'wgUserLanguage' ) ) will return -1, and the splice() call will remove the last element of the array (an arbitrary language), instead of (as intended) the user interface language (to be added to the front of the array with the unshift() call below).

Example:
Q42?uselang=en-gb (assuming your babel doesn’t include en-gb; see also T297393#7910267.

Screenshots/mockups:
Original termbox, before JS runs:

image.png (373×933 px, 51 KB)

JS-updated termbox, now without Portuguese:
image.png (373×933 px, 46 KB)

BDD
GIVEN
AND
WHEN
AND
THEN
AND

Acceptance criteria:

Open questions:

Event Timeline

There’s every chance that there’s an existing task for this bug, but I couldn’t find it.

Change 789862 had a related patch set uploaded (by Lucas Werkmeister (WMDE); author: Lucas Werkmeister (WMDE)):

[mediawiki/extensions/Wikibase@master] Fix wb.getUserLanguages() if user language not in babel

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

There’s every chance that there’s an existing task for this bug, but I couldn’t find it.

There is also every chance that this is the first time that it got noticed plus reported, wow! :)

Change 789862 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] Fix wb.getUserLanguages() if user language not in babel

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