Always display assistant languages where available

Assistant languages are chosen by users in a wiki with
Translate extension. If assistant languages are defined,
use that also for predicting the languages in compact list.

Bug: 62342
Change-Id: I25f42f3802e80baf5d4724ba6e42e00b8be2349e
This commit is contained in:
Nemo bis
2014-05-11 17:07:03 +02:00
committed by Santhosh
parent eb600dfbee
commit 625334fe63

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.