Merge "Always display assistant languages where available"
This commit is contained in:
@@ -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.
|
||||||
|
|||||||
Reference in New Issue
Block a user