Santhosh has uploaded a new change for review. https://gerrit.wikimedia.org/r/244636
Change subject: Suggestions: Improve the source and target language identification ...................................................................... Suggestions: Improve the source and target language identification * Avoided the cases of English appearing as target language * Also avoided the case of 'Any language' appearing as source or target * At any case if souce=target or either of them as null, we show 'no suggestions' message. Bug: T114888 Bug: T113704 Change-Id: I9da3a658aea9ce24ad0525f7888a443e8e623aad --- M modules/dashboard/ext.cx.suggestionlist.js 1 file changed, 15 insertions(+), 19 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation refs/changes/36/244636/1 diff --git a/modules/dashboard/ext.cx.suggestionlist.js b/modules/dashboard/ext.cx.suggestionlist.js index 459156f..1394296 100644 --- a/modules/dashboard/ext.cx.suggestionlist.js +++ b/modules/dashboard/ext.cx.suggestionlist.js @@ -26,7 +26,6 @@ this.$confirmationDialog = null; this.sourceLanguage = null; this.targetLanguage = null; - this.languages = []; this.promise = null; this.queryContinue = null; this.hasMore = true; @@ -49,7 +48,8 @@ }; CXSuggestionList.prototype.initLanguages = function () { - var storedTargetLanguage, storedSourceLanguage; + var storedTargetLanguage, storedSourceLanguage, + query = new mw.Uri().query; try { storedTargetLanguage = localStorage.getItem( 'cxTargetLanguage' ); @@ -57,25 +57,18 @@ } catch ( e ) { // Local storage disabled? } - // Try to get all possble languages. - this.languages = [ - storedSourceLanguage, - storedTargetLanguage, - 'en', - mw.config.get( 'wgContentLanguage' ), - mw.config.get( 'wgUserLanguage' ) - ]; - // Also add ULS defined common languages. - this.languages = this.languages.concat( mw.uls.getFrequentLanguageList() ); - // Get unique list. - this.languages = mw.cx.unique( this.languages ); - // At the end, this list will have some items. + + // Find a sensible language pair. + this.sourceLanguage = query.from || storedSourceLanguage || 'en'; + this.targetLanguage = query.to || storedTargetLanguage || mw.config.get( 'wgContentLanguage' ); + if ( this.sourceLanguage === this.targetLanguage ) { + this.targetLanguage = 'es'; + // In case this is also same as source language, nothing breaks. + } this.filters = { - sourceLanguage: this.languages[ 0 ], - targetLanguage: this.languages[ 1 ] + sourceLanguage: this.sourceLanguage, + targetLanguage: this.targetLanguage }; - // If suggestionTo is undefined, nothing breaks. The selector will show - // 'To any language' }; CXSuggestionList.prototype.loadItems = function () { @@ -112,6 +105,9 @@ } } ).fail( function () { this.promise = null; + self.$emptySuggestionList = self.buildEmptySuggestionList(); + self.$suggestionList.append( self.$emptySuggestionList ); + self.$emptySuggestionList.show(); } ); return promise; -- To view, visit https://gerrit.wikimedia.org/r/244636 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I9da3a658aea9ce24ad0525f7888a443e8e623aad Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/ContentTranslation Gerrit-Branch: master Gerrit-Owner: Santhosh <santhosh.thottin...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits