Merge "Resolve language code redirects before using them in ULS"

This commit is contained in:
jenkins-bot
2016-04-06 09:09:32 +00:00
committed by Gerrit Code Review

View File

@@ -82,7 +82,7 @@
var language; var language;
for ( language in this.compactList ) { for ( language in this.compactList ) {
this.showLanguage( language ); this.compactList[ language ].element.parentNode.style.display = '';
} }
this.addTrigger(); this.addTrigger();
@@ -137,8 +137,13 @@
this.$menu.css( 'left', this.left ); this.$menu.css( 'left', this.left );
}, },
languageDecorator: function ( $languageLink, language ) { languageDecorator: function ( $languageLink, language ) {
// set href according to language // set href and text exactly same as what was in
$languageLink.prop( 'href', compactLinks.interlanguageList[ language ].href ); // 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 // Use compact version of ULS
compact: true, compact: true,
@@ -267,9 +272,14 @@
var interlanguageList = {}; var interlanguageList = {};
this.$interlanguageList.find( 'li.interlanguage-link > a' ).each( function () { 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' ), href: this.getAttribute( 'href' ),
autonym: $( this ).text() autonym: $( this ).text(),
element: this
}; };
} ); } );
@@ -307,15 +317,6 @@
this.$interlanguageList.append( $trigger ); this.$interlanguageList.append( $trigger );
this.$trigger = $trigger; this.$trigger = $trigger;
},
/**
* Show a language from the interlanguage list
*
* @param {string} language
*/
showLanguage: function ( language ) {
this.$interlanguageList.find( '.interwiki-' + language ).css( 'display', '' );
} }
}; };