Skip to content

Commit

Permalink
Merge "Move "mul" to the top of the termbox"
Browse files Browse the repository at this point in the history
  • Loading branch information
jenkins-bot authored and Gerrit Code Review committed Nov 20, 2024
2 parents 22a4a1c + 66115bd commit 9873ebe
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions repo/includes/Hooks/OutputPageBeforeHTMLHookHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ private function getTermsLanguages(
$this->repoSettings->getSetting( 'tmpEnableMulLanguageCode' )
&& $this->repoSettings->getSetting( 'tmpAlwaysShowMulLanguageCode' )
) {
return array_merge( $userPreferredTermsLanguages, [ 'mul' ] );
return array_merge( [ 'mul' ], $userPreferredTermsLanguages );
}

// Check both the html snippets and the (possibly empty) entity for a "mul" term.
Expand All @@ -281,8 +281,8 @@ private function getTermsLanguages(
}

if ( $hasMulTerm ) {
// There is a "mul" term present, show as last entry in the term box.
return array_merge( $userPreferredTermsLanguages, [ 'mul' ] );
// There is a "mul" term present, show as first entry in the term box.
return array_merge( [ 'mul' ], $userPreferredTermsLanguages );
}
return $userPreferredTermsLanguages;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
}

PARENT.prototype._create.call( this );
this._defaultLanguages = this.options.userLanguages;
this._defaultLanguages = this.options.userLanguages.slice();

this._amendDefaultLanguages();

Expand All @@ -119,7 +119,7 @@
}
}

this._defaultLanguages.push( 'mul' );
this._defaultLanguages.unshift( 'mul' );
},

/**
Expand Down Expand Up @@ -162,8 +162,8 @@
.match( /(?:^|\s)wikibase-entitytermsforlanguageview-(\S+)/ );
if ( match && match[ 1 ] !== languages[ i ] ) {
if ( match[ 1 ] !== 'mul' ) {
// "mul" might be included in the existing term box, but we want it to be after
// everything else, thus discarding it is expected.
// "mul" might be included in the existing term box, but we want it to be the
// first entry, thus discarding it is expected.
mw.log.warn( 'Existing entitytermsforlanguagelistview DOM does not match configured languages' );
}
mismatchAt = i;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@

assert.deepEqual(
entitytermsforlanguagelistview._defaultLanguages,
[ 'de', 'en', 'mul' ],
[ 'mul', 'de', 'en' ],
'Default languages if a "mul" term is present.'
);
} );
Expand All @@ -194,7 +194,7 @@

assert.deepEqual(
entitytermsforlanguagelistview._defaultLanguages,
[ 'de', 'en', 'mul' ],
[ 'mul', 'de', 'en' ],
'"mul" should always be added to the default languages, even if it has no term.'
);
} );
Expand Down

0 comments on commit 9873ebe

Please sign in to comment.