Resolve language code redirects before using them in ULS
Interlanguage lists can contain language codes that are redirects in language data of ULS. For example, sr is a redirect to sr-cyrl. So, if sr is passes as one of the language to ULS, its region, script grouping is failing and the end result will be missing them in the ULS language list. This should be properly fixed in jquery.uls library. Tracked at https://github.com/wikimedia/jquery.uls/issues/207 In this patch we are following a simple approach of passing the language codes to ULS as redirect resolved. Bug: T100002 Bug: T131005 Bug: T126909 Bug: T123834 Change-Id: I8b89edb60b4d2c6f2b25c8589569f748c5523722
This commit is contained in:
committed by
Niklas Laxström
parent
d013ae5ebf
commit
6ffd42c07a
@@ -82,7 +82,7 @@
|
||||
var language;
|
||||
|
||||
for ( language in this.compactList ) {
|
||||
this.showLanguage( language );
|
||||
this.compactList[ language ].element.parentNode.style.display = '';
|
||||
}
|
||||
|
||||
this.addTrigger();
|
||||
@@ -137,8 +137,13 @@
|
||||
this.$menu.css( 'left', this.left );
|
||||
},
|
||||
languageDecorator: function ( $languageLink, language ) {
|
||||
// set href according to language
|
||||
$languageLink.prop( 'href', compactLinks.interlanguageList[ language ].href );
|
||||
// set href and text exactly same as what was in
|
||||
// interlanguage link. The ULS autonym might be different in some
|
||||
// cases like sr. In ULS it is "српски", while in interlanguage links
|
||||
// it is "српски / srpski"
|
||||
$languageLink
|
||||
.prop( 'href', compactLinks.interlanguageList[ language ].href )
|
||||
.text( compactLinks.interlanguageList[ language ].autonym );
|
||||
},
|
||||
// Use compact version of ULS
|
||||
compact: true,
|
||||
@@ -267,9 +272,14 @@
|
||||
var interlanguageList = {};
|
||||
|
||||
this.$interlanguageList.find( 'li.interlanguage-link > a' ).each( function () {
|
||||
interlanguageList[ this.getAttribute( 'lang' ) ] = {
|
||||
var langCode = this.getAttribute( 'lang' );
|
||||
|
||||
// We keep interlanguageList with redirect resolved language codes as keys.
|
||||
langCode = $.uls.data.isRedirect( langCode ) || langCode;
|
||||
interlanguageList[ langCode ] = {
|
||||
href: this.getAttribute( 'href' ),
|
||||
autonym: $( this ).text()
|
||||
autonym: $( this ).text(),
|
||||
element: this
|
||||
};
|
||||
} );
|
||||
|
||||
@@ -307,15 +317,6 @@
|
||||
|
||||
this.$interlanguageList.append( $trigger );
|
||||
this.$trigger = $trigger;
|
||||
},
|
||||
|
||||
/**
|
||||
* Show a language from the interlanguage list
|
||||
*
|
||||
* @param {string} language
|
||||
*/
|
||||
showLanguage: function ( language ) {
|
||||
this.$interlanguageList.find( '.interwiki-' + language ).css( 'display', '' );
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user