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:
@@ -174,6 +174,9 @@
|
||||
compact: function ( languages ) {
|
||||
var compactLanguages = [];
|
||||
|
||||
// Add user-defined assistant languages on wikis with Translate extension.
|
||||
compactLanguages = compactLanguages.concat( this.filterByAssistantLanguages() );
|
||||
|
||||
// Add previously selected languages.
|
||||
// Previous languages are always the better suggestion
|
||||
// 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
|
||||
* by the article and fetch their href.
|
||||
|
||||
Reference in New Issue
Block a user