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

Change subject: Support <poem> translations
......................................................................


Support <poem> translations

Adapt the poem (mw:Extension/poem) from the source article to the
target article.

Editing the poem text is not supported. If there is MT, the translation
will be used for target article.

Testplan:
Translate an article with poem in it. Example:
https://en.wikipedia.org/wiki/Puja_%28Hinduism%29
After translating, ensure that translation has poem with content in it.

Bug: T100385
Change-Id: I98d29f889b9afd4497898a2edbfce5366e5e719e
---
M extension.json
A modules/tools/ext.cx.tools.poem.js
2 files changed, 44 insertions(+), 0 deletions(-)

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



diff --git a/extension.json b/extension.json
index 0d09ca0..9c3d7f8 100644
--- a/extension.json
+++ b/extension.json
@@ -372,6 +372,7 @@
                                "ext.cx.tools.dictionary",
                                "ext.cx.tools.formatter",
                                "ext.cx.tools.gallery",
+                               "ext.cx.tools.poem",
                                "ext.cx.tools.images",
                                "ext.cx.tools.instructions",
                                "ext.cx.tools.link",
@@ -543,6 +544,11 @@
                                "tools/ext.cx.tools.gallery.js"
                        ]
                },
+               "ext.cx.tools.poem": {
+                       "scripts": [
+                               "tools/ext.cx.tools.poem.js"
+                       ]
+               },
                "ext.cx.tools.categories": {
                        "scripts": [
                                "tools/ext.cx.tools.categories.js"
diff --git a/modules/tools/ext.cx.tools.poem.js 
b/modules/tools/ext.cx.tools.poem.js
new file mode 100644
index 0000000..54fba4f
--- /dev/null
+++ b/modules/tools/ext.cx.tools.poem.js
@@ -0,0 +1,38 @@
+/**
+ * ContentTranslation Tools
+ * A tool that allows editors to translate pages from one language
+ * to another with the help of machine translation and other translation tools
+ *
+ * @file
+ * @ingroup Extensions
+ * @copyright See AUTHORS.txt
+ * @license GPL-2.0+
+ */
+( function ( $, mw ) {
+       'use strict';
+
+       function adaptPoem( $section ) {
+               var $sourceSection, poemData, $poem;
+
+               $sourceSection = mw.cx.getSourceSection( $section.data( 
'source' ) );
+               if ( $section.is( '[typeof*="mw:Extension/poem"]' ) ) {
+                       $poem = $sourceSection;
+               } else {
+                       $poem = $sourceSection.find( 
'[typeof*="mw:Extension/poem"]' );
+               }
+               if ( !$poem.length ) {
+                       return;
+               }
+               poemData = $poem.data( 'mw' );
+               // TODO: Note that we are not retaining markup here.
+               poemData.body.extsrc = $poem.text().replace( /<br\s*\/?>/mg, 
'\n' );
+               // Copy the data-mw to target section.
+               $section.find( '[typeof*="mw:Extension/poem"]' ).attr( 
'data-mw', JSON.stringify( poemData ) );
+               // Make the poem readonly. We can only adapt them. Not allowing 
edits.
+               $section.find( 'p' ).attr( 'contenteditable', false );
+       }
+
+       $( function () {
+               mw.hook( 'mw.cx.translation.postMT' ).add( adaptPoem );
+       } );
+}( jQuery, mediaWiki ) );

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I98d29f889b9afd4497898a2edbfce5366e5e719e
Gerrit-PatchSet: 4
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: KartikMistry <kartik.mis...@gmail.com>
Gerrit-Reviewer: Legoktm <legoktm.wikipe...@gmail.com>
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