Santhosh has uploaded a new change for review.

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

Change subject: Show a warning when a section with manual changes getting 
overwritten
......................................................................

Show a warning when a section with manual changes getting overwritten

Content will get overwritten when using the buttons or menus from
the MT card. Show a warning since it overwrites translators manual
changes. If translator confirm the action, proceed.

We are using a simple native confirmation dialog here for now.
This can be improved with a OOJS widget when we start using them.

Change-Id: Ieb1055a0f5d1bea009599f4879defd5665f261b6
---
M extension.json
M i18n/en.json
M i18n/qqq.json
M modules/tools/ext.cx.tools.mt.js
4 files changed, 22 insertions(+), 8 deletions(-)


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

diff --git a/extension.json b/extension.json
index ea27279..5d5c23a 100644
--- a/extension.json
+++ b/extension.json
@@ -522,7 +522,8 @@
                                "cx-tools-mt-restore",
                                "cx-tools-mt-provider-title",
                                "cx-tools-mt-not-available",
-                               "cx-tools-mt-dont-use"
+                               "cx-tools-mt-dont-use",
+                               "cx-tools-mt-section-overwrite-warning"
                        ],
                        "dependencies": [
                                "ext.cx.model",
diff --git a/i18n/en.json b/i18n/en.json
index 142765b..c30e2a1 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -75,6 +75,7 @@
        "cx-tools-mt-provider-title": "From $1",
        "cx-tools-mt-not-available": "Not available for $1",
        "cx-tools-mt-dont-use": "Don't use machine translation",
+       "cx-tools-mt-section-overwrite-warning": "Translation for this section 
will be overwritten.",
        "cx-tools-categories-count-message": "{{PLURAL:$1|$1 category|$1 
categories|0=No categories}}",
        "cx-stats-title": "Content Translation statistics",
        "cx-stats-unknown": "unknown",
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 520a025..d3e29e5 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -80,6 +80,7 @@
        "cx-tools-mt-provider-title": "An item in a menu in the machine 
translation tool card on Special:ContentTranslation. The menu lists different 
available machine translation providers for this language.\n* $1 is the name of 
the provider, such as Apertium, Microsoft Translator, Google Translate, 
etc.\n{{Identical|From}}",
        "cx-tools-mt-not-available": "An item in a menu in the machine 
translation tool card on Special:ContentTranslation. It's shown when there is 
no machine translation provider for that language. $1 is the name of the 
language.",
        "cx-tools-mt-dont-use": "An item in a menu in the machine translation 
tool card on Special:ContentTranslation. Other items in same menu will use the 
message {{msg-mw|cx-tools-mt-from-provider}}. Selecting this item disables 
machine translation. It may be the default for some languages.",
+       "cx-tools-mt-section-overwrite-warning": "A warning message shown when 
the current section is about to be overwritten",
        "cx-tools-categories-count-message": "Indicates the number of 
categories associated with the page.\n\nDisplayed at the top of source and 
translation columns in [[Special:ContentTranslation]].\n\nParameters:\n* $1 - 
number of categories\n{{Identical|Category}}",
        "cx-stats-title": "The title for the Special:ContentTranslationStats 
special page.",
        "cx-stats-unknown": "Text when the source or target language is 
unknown. An adjective that describes the language.\n{{Identical|Unknown}}",
diff --git a/modules/tools/ext.cx.tools.mt.js b/modules/tools/ext.cx.tools.mt.js
index bb08f89..2663859 100644
--- a/modules/tools/ext.cx.tools.mt.js
+++ b/modules/tools/ext.cx.tools.mt.js
@@ -339,8 +339,12 @@
         */
        MTControlCard.prototype.useSource = function () {
                var sourceId = this.$section.data( 'source' );
-               // Use the source without machine translation
-               mw.hook( 'mw.cx.translation.add' ).fire( sourceId, 'source' );
+               if ( this.$section.attr( 'data-cx-state' ) === 'mt' ||
+                       window.confirm( mw.msg( 
'cx-tools-mt-section-overwrite-warning' ) )
+               ) {
+                       // Use the source without machine translation
+                       mw.hook( 'mw.cx.translation.add' ).fire( sourceId, 
'source' );
+               }
        };
 
        /**
@@ -350,9 +354,13 @@
         */
        MTControlCard.prototype.restoreTranslation = function () {
                var sourceId = this.$section.data( 'source' );
-               // Use the source without machine translation
-               mw.hook( 'mw.cx.translation.add' ).fire( sourceId, 'restore' );
-               this.stop();
+               if ( this.$section.attr( 'data-cx-state' ) === 'mt' ||
+                       window.confirm( mw.msg( 
'cx-tools-mt-section-overwrite-warning' ) )
+               ) {
+                       // Use the source without machine translation
+                       mw.hook( 'mw.cx.translation.add' ).fire( sourceId, 
'restore' );
+                       this.stop();
+               }
        };
 
        /**
@@ -360,8 +368,11 @@
         */
        MTControlCard.prototype.clearTranslation = function () {
                var sourceId = this.$section.data( 'source' );
-
-               mw.hook( 'mw.cx.translation.add' ).fire( sourceId, 'clear' );
+               if ( this.$section.attr( 'data-cx-state' ) === 'mt' ||
+                       window.confirm( mw.msg( 
'cx-tools-mt-section-overwrite-warning' ) )
+               ) {
+                       mw.hook( 'mw.cx.translation.add' ).fire( sourceId, 
'clear' );
+               }
        };
 
        MTControlCard.prototype.selectProvider = function ( providerId ) {

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

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