jenkins-bot has submitted this change and it was merged.

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


Make sure <references> not getting removed from source

Test translating Dong_Qichang from fr to some other language where we
do not have a source configuration to whitelist references transclusion

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

Approvals:
  Nikerabbit: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/modules/source/ext.cx.source.filter.js 
b/modules/source/ext.cx.source.filter.js
index fe5940c..9884eac 100644
--- a/modules/source/ext.cx.source.filter.js
+++ b/modules/source/ext.cx.source.filter.js
@@ -69,6 +69,22 @@
        }
 
        /**
+        * Check if the template contains <references> transclusion
+        * @param {jQuery} $template
+        * @return {boolean} Whether the template contains <references> or not.
+        */
+       function hasReferences( $template ) {
+               if (
+                       $template.is( '[typeof*="mw:Extension/references"]' ) ||
+                       $template.find( '[typeof*="mw:Extension/references"]' 
).length
+               ) {
+                       return true;
+               }
+
+               return false;
+       }
+
+       /**
         * Filter the templates present in the source article based on the 
configuration.
         * @param {Object} [configuration]
         */
@@ -122,6 +138,13 @@
 
                        if ( isInlineTemplate( $template ) ) {
                                mw.log( '[CX] Keeping inline template: ' + 
templateName );
+                               return;
+                       }
+                       // Check whether this template contains <references>.
+                       // If so, let it pass even without being whitelisted in 
the template configuration
+                       // because we want references to appear in the 
published translation.
+                       if ( hasReferences( $template ) ) {
+                               mw.log( '[CX] Keeping references transclusion: 
' + 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: merged
Gerrit-Change-Id: I0afd066c9449484aacdc07e1d21a740341db9706
Gerrit-PatchSet: 5
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Santhosh <[email protected]>
Gerrit-Reviewer: Amire80 <[email protected]>
Gerrit-Reviewer: Nikerabbit <[email protected]>
Gerrit-Reviewer: Santhosh <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to