jenkins-bot has submitted this change and it was merged. Change subject: Fixes when language code and domain differ ......................................................................
Fixes when language code and domain differ The toolserver tool handles redirects itself, so it was not changed in this patch. All instances of lllang parameter were changed. Testplan: Translate Tapethok from en to bho Without this patch, the user is not notified that the page already exists in the language. Translate LaTeX from simple to bho Without this patch, user will see all links in translation template as missing. With this patch, links will be adapted correctly. Bug: T99888 Change-Id: I2d5021c27f8b03563ef5a16723bed3ea83d0e701 --- M modules/base/ext.cx.sitemapper.js M modules/source/ext.cx.source.selector.js M modules/tools/ext.cx.tools.categories.js M modules/tools/ext.cx.tools.link.js 4 files changed, 34 insertions(+), 23 deletions(-) Approvals: Santhosh: Looks good to me, approved Nikerabbit: Looks good to me, but someone else must approve jenkins-bot: Verified diff --git a/modules/base/ext.cx.sitemapper.js b/modules/base/ext.cx.sitemapper.js index 6d7aa72..bed8b0c 100644 --- a/modules/base/ext.cx.sitemapper.js +++ b/modules/base/ext.cx.sitemapper.js @@ -11,21 +11,6 @@ ( function ( $, mw ) { 'use strict'; - // Some wikis have domain names that do not match the content language. - // See: wgLanguageCode in operations/mediawiki-config/wmf-config/InitialiseSettings.php - // NOTE: Keep list of mapping in sync with includes/SiteMapper.php - var languageToWikiDomainMapping = { - bho: 'bh', - 'crh-latn': 'crh', - gsw: 'als', - sgs: 'bat-smg', - 'be-tarask': 'be-x-old', - vro: 'fiu-vro', - rup: 'roa-rup', - lzh: 'zh-classical', - nan: 'zh-min-nan', - yue: 'zh-yue' - }; /** * Handles providing urls to different wikis. @@ -35,6 +20,31 @@ this.config = siteconfig; }; + + /** + * Some wikis have domain names that do not match the content language. + * See: wgLanguageCode in operations/mediawiki-config/wmf-config/InitialiseSettings.php + * NOTE: Keep list of mapping in sync with includes/SiteMapper.php + * @param {string} language Language code + * @return {string} + */ + mw.cx.SiteMapper.prototype.getWikiDomainCode = function ( language ) { + var languageToWikiDomainMapping = { + bho: 'bh', + 'crh-latn': 'crh', + gsw: 'als', + sgs: 'bat-smg', + 'be-tarask': 'be-x-old', + vro: 'fiu-vro', + rup: 'roa-rup', + lzh: 'zh-classical', + nan: 'zh-min-nan', + yue: 'zh-yue' + }; + + return languageToWikiDomainMapping[ language ] || language; + }; + /** * Get the API for a remote wiki. * @@ -42,10 +52,10 @@ * @return {mediawiki.Api} */ mw.cx.SiteMapper.prototype.getApi = function ( language ) { - var url; + var url, domain; - language = languageToWikiDomainMapping[ language ] || language; - url = this.config.api.replace( '$1', language ); + domain = this.getWikiDomainCode( language ); + url = this.config.api.replace( '$1', domain ); return new mw.Api( { ajax: { url: url @@ -63,15 +73,16 @@ */ mw.cx.SiteMapper.prototype.getPageUrl = function ( language, title, params ) { var base = this.config.view, + domain, extra = ''; - language = languageToWikiDomainMapping[ language ] || language; + domain = this.getWikiDomainCode( language ); if ( params && !$.isEmptyObject( params ) ) { base = this.config.action || this.config.view; extra = ( base.indexOf( '?' ) !== -1 ? '&' : '?' ) + $.param( params ); } - return base.replace( '$1', language ).replace( '$2', title ) + extra; + return base.replace( '$1', domain ).replace( '$2', title ) + extra; }; /** diff --git a/modules/source/ext.cx.source.selector.js b/modules/source/ext.cx.source.selector.js index b00854f..bf35c23 100644 --- a/modules/source/ext.cx.source.selector.js +++ b/modules/source/ext.cx.source.selector.js @@ -474,7 +474,7 @@ action: 'query', prop: 'langlinks', titles: sourceTitle, - lllang: targetLanguage, + lllang: mw.cx.siteMapper.getWikiDomainCode( targetLanguage ), lllimit: 1, redirects: true, format: 'json' diff --git a/modules/tools/ext.cx.tools.categories.js b/modules/tools/ext.cx.tools.categories.js index 6b70325..49fd950 100644 --- a/modules/tools/ext.cx.tools.categories.js +++ b/modules/tools/ext.cx.tools.categories.js @@ -546,7 +546,7 @@ action: 'query', titles: categoryTitles.join( '|' ), prop: 'langlinks', - lllang: language, + lllang: mw.cx.siteMapper.getWikiDomainCode( language ), lllimit: 100, redirects: true, format: 'json' diff --git a/modules/tools/ext.cx.tools.link.js b/modules/tools/ext.cx.tools.link.js index 6d6e96c..26e8d30 100644 --- a/modules/tools/ext.cx.tools.link.js +++ b/modules/tools/ext.cx.tools.link.js @@ -77,7 +77,7 @@ titles: titles.join( '|' ), prop: 'langlinks', lllimit: titles.length, // TODO: Default is 10 and max is 500. Do we need more than 500? - lllang: language, + lllang: mw.cx.siteMapper.getWikiDomainCode( language ), redirects: true, format: 'json' }, { -- To view, visit https://gerrit.wikimedia.org/r/217251 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I2d5021c27f8b03563ef5a16723bed3ea83d0e701 Gerrit-PatchSet: 7 Gerrit-Project: mediawiki/extensions/ContentTranslation Gerrit-Branch: master Gerrit-Owner: Santhosh <santhosh.thottin...@gmail.com> Gerrit-Reviewer: KartikMistry <kartik.mis...@gmail.com> Gerrit-Reviewer: Nemo bis <federicol...@tiscali.it> Gerrit-Reviewer: Nikerabbit <niklas.laxst...@gmail.com> Gerrit-Reviewer: Santhosh <santhosh.thottin...@gmail.com> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits