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

Change subject: Gallery: Adapt the image namespaces to canonical File namespace
......................................................................


Gallery: Adapt the image namespaces to canonical File namespace

Testplan:
Follow https://www.mediawiki.org/wiki/Topic:Skpyp184cw2z3rtr

Bug: T105799
Change-Id: Id48116cca70444f7a6c6daf7c34d5e3acb8db814
---
M modules/tools/ext.cx.tools.gallery.js
1 file changed, 7 insertions(+), 2 deletions(-)

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



diff --git a/modules/tools/ext.cx.tools.gallery.js 
b/modules/tools/ext.cx.tools.gallery.js
index f44cee2..89fae3b 100644
--- a/modules/tools/ext.cx.tools.gallery.js
+++ b/modules/tools/ext.cx.tools.gallery.js
@@ -13,7 +13,7 @@
 
        function adaptGallery( $section ) {
                var i, $sourceSection, galleryData, galleryWikiMarkup = '',
-                       imageItems, caption, imageIndex = 0;
+                       imageItems, caption, imageTitle, imageIndex = 0;
 
                if ( !$section.is( '[typeof*="mw:Extension/gallery"]' ) ) {
                        return;
@@ -29,8 +29,13 @@
                                // FIXME: Copying plain text of gallery text 
will definitely lose the html
                                // mark up in translation. What we need is 
Wikitext of the translated HTML.
                                // That require a restbase api call.
+                               imageTitle = imageItems[ i ].split( '|' )[ 0 ];
+                               // Change the image namespace to canonical 
File: namespace.
+                               // TODO: We can use the localized namespace in 
target language with the
+                               // help of an API query.
+                               imageTitle = imageTitle.replace( /(.+:)/, 
'File:' );
                                caption = $section.find( '.gallerytext' ).eq( 
imageIndex ).text().trim();
-                               imageItems[ i ] = [ imageItems[ i ].split( '|' 
)[ 0 ], caption ].join( '|' );
+                               imageItems[ i ] = [ imageTitle, caption ].join( 
'|' );
                                imageIndex++;
                        }
                }

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Id48116cca70444f7a6c6daf7c34d5e3acb8db814
Gerrit-PatchSet: 6
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Santhosh <santhosh.thottin...@gmail.com>
Gerrit-Reviewer: Amire80 <amir.ahar...@mail.huji.ac.il>
Gerrit-Reviewer: Nikerabbit <niklas.laxst...@gmail.com>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to