Merge "Always display assistant languages where available"

This commit is contained in:
jenkins-bot
2014-05-27 04:04:12 +00:00
committed by Gerrit Code Review

View File

@@ -174,6 +174,9 @@
compact: function ( languages ) { compact: function ( languages ) {
var compactLanguages = []; var compactLanguages = [];
// Add user-defined assistant languages on wikis with Translate extension.
compactLanguages = compactLanguages.concat( this.filterByAssistantLanguages() );
// Add previously selected languages. // Add previously selected languages.
// Previous languages are always the better suggestion // Previous languages are always the better suggestion
// because the user has explicitly chosen them. // because the user has explicitly chosen them.
@@ -223,6 +226,23 @@
} ); } );
}, },
/**
* Filter the language list by Translate's assistant languages.
* Where available, they're languages deemed useful by the user.
* @return {Array} List of those language codes which are supported by article
*/
filterByAssistantLanguages: function ( languages ) {
var assistantLanguages = mw.user.options.get( 'translate-editlangs' );
if ( assistantLanguages && assistantLanguages !== 'default' ) {
return $.grep( assistantLanguages.split(/,\s*/), function ( language ) {
return $.inArray( language, languages ) >= 0;
} );
}
return [];
},
/** /**
* Find out the existing languages supported * Find out the existing languages supported
* by the article and fetch their href. * by the article and fetch their href.