Santhosh has uploaded a new change for review. https://gerrit.wikimedia.org/r/240076
Change subject: Do not call cxserver to display gray interwiki link ...................................................................... Do not call cxserver to display gray interwiki link Adds a simple check to filter out language codes like ml-IN, en-US etc coming from browser languages. To make it future-proof, we just check if language code is known to ULS Re-reverts If0c329ad4094498b593df91521b28116f2804224 Bug: T110246 Change-Id: Ic1ad144b442b9f208d12466490545eee1c8a5083 --- M modules/entrypoint/ext.cx.interlanguagelink.js 1 file changed, 5 insertions(+), 41 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation refs/changes/76/240076/1 diff --git a/modules/entrypoint/ext.cx.interlanguagelink.js b/modules/entrypoint/ext.cx.interlanguagelink.js index c92089f..2fcf858 100644 --- a/modules/entrypoint/ext.cx.interlanguagelink.js +++ b/modules/entrypoint/ext.cx.interlanguagelink.js @@ -19,11 +19,9 @@ * - Accept-Language. * - Browser interface language. * This will probably include more languages in the future. - * @param {String[]} availableTargetLanguages A list of target languages - * that are supported by this instance. * @return {string[]} target languages */ - function getSuggestedTargetLanguages( availableTargetLanguages ) { + function getSuggestedTargetLanguages() { var specialCode, specialCodes, specialCodeIndex, uniquePossibleTargetLanguages, possibleTargetLanguages = [], @@ -53,42 +51,10 @@ uniquePossibleTargetLanguages = mw.cx.unique( possibleTargetLanguages ); return $.grep( uniquePossibleTargetLanguages, function ( language ) { - return ( - $.inArray( language, availableTargetLanguages ) > -1 && - language !== pageLanguage - ); + return language !== pageLanguage && + // Known language for ULS + language !== $.uls.data.getAutonym( language ); } ); - } - - /** - * Get the list of target languages that this instance of CX supports. - * @return {jQuery.Promise} - */ - function getAvailableTargetLanguages() { - var languagePairsAPIUrl, deferred; - - // Optimization: creating the cxserver URL without sitemapper - // to avoid loading the sitemapper module just for this. - languagePairsAPIUrl = - mw.config.get( 'wgContentTranslationSiteTemplates' ).cx + '/languagepairs'; - - deferred = $.Deferred(); - - $.get( languagePairsAPIUrl ) - .done( function ( response ) { - deferred.resolve( response.target || [] ); - } ) - .fail( function ( response ) { - mw.log( - 'Error getting language pairs from ' + languagePairsAPIUrl + ' . ' + - response.statusText + ' (' + response.status + '). ' + - response.responseText - ); - - deferred.reject(); - } ); - - return deferred.promise(); } /** @@ -181,8 +147,6 @@ } $( function () { - getAvailableTargetLanguages().then( function ( availableTargetLanguages ) { - prepareCXInterLanguageLinks( availableTargetLanguages ); - } ); + prepareCXInterLanguageLinks(); } ); }( jQuery, mediaWiki ) ); -- To view, visit https://gerrit.wikimedia.org/r/240076 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ic1ad144b442b9f208d12466490545eee1c8a5083 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