Santhosh has uploaded a new change for review. https://gerrit.wikimedia.org/r/306188
Change subject: Templates: Fixes for inline template adaptation ...................................................................... Templates: Fixes for inline template adaptation * When the template is missing template data and is a redirect like Template:Citation needed in gu.wikipedia, the template mapping will not have 'title' key causing the entire template not mapped. This commit fixes it * When the target template does not accept any params, while source template has params, consider the template adaptation successful This also happens in the case of gu.wikipedia citation needed template. In English, this template accepts date parameter, while gu.wikipedia does not accept any params. This is partial fix for T95391 Change-Id: Ia2047991a89e4c75262e46c62d6926ee45f1fd87 --- M modules/tools/ext.cx.tools.template.js 1 file changed, 13 insertions(+), 5 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation refs/changes/88/306188/1 diff --git a/modules/tools/ext.cx.tools.template.js b/modules/tools/ext.cx.tools.template.js index dc27153..784cc63 100644 --- a/modules/tools/ext.cx.tools.template.js +++ b/modules/tools/ext.cx.tools.template.js @@ -134,16 +134,18 @@ // This prevents warnings about the unrecognized parameter "_" cache: true } ).then( function ( resp ) { - var pageContent = ''; + var title, pageContent = ''; if ( resp.query.pages[ resp.query.pageids[ 0 ] ].revisions && resp.query.pages[ resp.query.pageids[ 0 ] ].revisions[ 0 ] ) { pageContent = resp.query.pages[ resp.query.pageids[ 0 ] ].revisions[ 0 ][ '*' ]; + title = resp.query.pages[ resp.query.pageids[ 0 ] ].title; } return { + title: title, params: self.extractParametersFromTemplateCode( pageContent ) }; } ); @@ -238,16 +240,22 @@ // Update the name of the template return this.getTemplateNamespaceTranslation( this.targetLanguage ) .then( function ( translatedNamespace ) { - var templateName, targetParams, targetName; + var templateName, sourceParams, targetParams, targetName; targetName = self.templateMapping.cxMapping.targetname || self.templateMapping.title; if ( !targetName ) { return false; } + sourceParams = self.getSourceParams(); + targetParams = self.getAdaptedTargetParams( sourceParams ); - targetParams = self.getAdaptedTargetParams( self.getSourceParams() ); - if ( $.isEmptyObject( targetParams ) ) { - return false; + if ( !$.isEmptyObject( sourceParams ) && $.isEmptyObject( targetParams ) ) { + if ( self.templateMapping.params && Object( self.templateMapping.params ).length > 0 ) { + // Checking whether there is any params defined for target template. + // It is possible that source template definition has params and target + // does not have any. Mapping failed only when target has some params. + return false; + } } // So we were able to map at least one parameter to the target template. -- To view, visit https://gerrit.wikimedia.org/r/306188 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ia2047991a89e4c75262e46c62d6926ee45f1fd87 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