Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/204487

Change subject: Make sure references templates not getting removed from source
......................................................................

Make sure references templates not getting removed from source

Test translating Dong_Qichang from fr to some other language where we
do not have a template configuration

Bug: T96239
Change-Id: I0afd066c9449484aacdc07e1d21a740341db9706
---
M modules/source/ext.cx.source.filter.js
1 file changed, 21 insertions(+), 0 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation 
refs/changes/87/204487/1

diff --git a/modules/source/ext.cx.source.filter.js 
b/modules/source/ext.cx.source.filter.js
index fe5940c..d5661a0 100644
--- a/modules/source/ext.cx.source.filter.js
+++ b/modules/source/ext.cx.source.filter.js
@@ -41,6 +41,20 @@
        }
 
        /**
+        * Check if the template is references
+        * @param {jQuery} $template
+        * @return {boolean} Whether the template is references or not.
+        */
+       function isReferences( $template ) {
+               if ( $template.is( '[typeof*="mw:Extension/references"]' ) ||
+                       $template.find( '[typeof*="mw:Extension/references"]' 
).length ) {
+                       return true;
+               }
+
+               return false;
+       }
+
+       /**
         * Simple check for inline templates.
         * @param {jQuery} $template
         * @return {boolean} Whether the template is inline or not.
@@ -122,6 +136,13 @@
 
                        if ( isInlineTemplate( $template ) ) {
                                mw.log( '[CX] Keeping inline template: ' + 
templateName );
+                               return;
+                       }
+                       // Even if the template configuration has not 
whitelisted the references
+                       // template, we must keep it to get the references in 
published article
+                       // working. So try to identify references template and 
keep it.
+                       if ( isReferences( $template ) ) {
+                               mw.log( '[CX] Keeping references template: ' + 
templateName );
                        } else {
                                mw.log( '[CX] Removing template: ' + 
templateName );
                                sourceFilter.removeTemplate( $template );

-- 
To view, visit https://gerrit.wikimedia.org/r/204487
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I0afd066c9449484aacdc07e1d21a740341db9706
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

Reply via email to