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

Change subject: Better announce new optional MT services available
......................................................................


Better announce new optional MT services available

Bug T128059 has an additional requirement that the green indicators
are never shown again once translator has chosen the new provider.
This is not done in this commit. It requires a way to persist
the provider preference. To be done in a different commit.

Note that the expected configuration to set a non default MT in cxserver
configuration with this patch is:

mt:
 defaults:
   'en-es': source-mt

Bug: T128059
Change-Id: I4bf8635a03ce21e334adbfdb9fffbb9963179699
---
M extension.json
M i18n/en.json
M i18n/qqq.json
M modules/tools/ext.cx.tools.mt.js
M modules/tools/styles/ext.cx.tools.mt.less
5 files changed, 63 insertions(+), 8 deletions(-)

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



diff --git a/extension.json b/extension.json
index 72d8d65..0959b2b 100644
--- a/extension.json
+++ b/extension.json
@@ -631,7 +631,9 @@
                                "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-new-provider",
+                               "cx-tools-mt-new-providers-available"
                        ],
                        "dependencies": [
                                "ext.cx.model",
diff --git a/i18n/en.json b/i18n/en.json
index 065af70..460e78a 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -213,5 +213,7 @@
        "cx-tools-linter-hide-details": "Hide details",
        "cx-translator-month-stats-label": "This month",
        "cx-translator-total-translations-label": "Total",
-       "cx-page-old-revision-loaded": "This translation is based on an older 
version of the content. The source page may have [$1 changed significantly]. 
You can continue this translation or start it again to use the updated content."
+       "cx-page-old-revision-loaded": "This translation is based on an older 
version of the content. The source page may have [$1 changed significantly]. 
You can continue this translation or start it again to use the updated 
content.",
+       "cx-tools-mt-new-provider": "new",
+       "cx-tools-mt-new-providers-available": "with new options"
 }
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 7f0a3ee..2af2b4c 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -219,5 +219,7 @@
        "cx-tools-linter-hide-details": "Label for abusefilter error 
hide/collapse link in linter card",
        "cx-translator-month-stats-label": "Label displayed in the translation 
statistics of current user.",
        "cx-translator-total-translations-label": "Label displayed in the 
translation statistics of current user.\n{{Identical|Total}}",
-       "cx-page-old-revision-loaded": "Warning message shown when the older 
revision of source page loaded"
+       "cx-page-old-revision-loaded": "Warning message shown when the older 
revision of source page loaded",
+       "cx-tools-mt-new-provider": "Label indicating the machine translation 
provider is a new option",
+       "cx-tools-mt-new-providers-available": "Label shown in machine 
translation card when there are new provider options"
 }
diff --git a/modules/tools/ext.cx.tools.mt.js b/modules/tools/ext.cx.tools.mt.js
index 0037c76..098a52c 100644
--- a/modules/tools/ext.cx.tools.mt.js
+++ b/modules/tools/ext.cx.tools.mt.js
@@ -433,13 +433,24 @@
        };
 
        MTControlCard.prototype.buildProvidersMenu = function () {
-               var provider, items;
+               var provider, items, nonDefaultMT, newProvider = false;
+
+               if ( MTControlCard.providers && MTControlCard.providers.length 
> 1 ) {
+                       nonDefaultMT = true;
+                       // There are more MT options or non default MT 
available. Announce.
+                       this.$card.find( '.card__title-row' )
+                               .addClass( 'card--new' )
+                               .append( $( '<div>' )
+                                       .text( mw.msg( 
'cx-tools-mt-new-providers-available' ) )
+                                       .addClass( 'card__new-providers' )
+                               );
+               }
 
                this.$providersMenu = $( '<ul>' )
                        .addClass( 'card__providers-menu' )
                        .hide();
 
-               items = MTControlCard.providers || [];
+               items = MTControlCard.providers.slice( 0 ); // Copy values.
                if ( items.indexOf( sourceMT ) < 0 ) {
                        items.push( sourceMT );
                }
@@ -448,8 +459,13 @@
                }
                // Add available machine translation engines to the menu
                for ( provider in items ) {
+                       if ( nonDefaultMT && [ sourceMT, disableMT, noMT 
].indexOf( items[ provider ] ) < 0 ) {
+                               newProvider = true;
+                       } else {
+                               newProvider = false;
+                       }
                        this.$providersMenu.append(
-                               this.getProviderItem( items[ provider ] )
+                               this.getProviderItem( items[ provider ], 
newProvider )
                        );
                }
 
@@ -481,14 +497,23 @@
         * @param {string} providerId Provider id.
         * @return {jQuery}
         */
-       MTControlCard.prototype.getProviderItem = function ( providerId ) {
-               return $( '<li>' )
+       MTControlCard.prototype.getProviderItem = function ( providerId, 
newProvider ) {
+               var $label, $new = $( [] );
+               $label = $( '<span>' )
                        .text( this.getProviderTitle( providerId ) )
                        .addClass( 'card__providers-menu-item' )
                        .attr( {
                                id: providerIdPrefix + providerId,
                                'data-provider': providerId
                        } );
+               if ( newProvider ) {
+                       $new = $( '<span>' )
+                               .text( mw.msg( 'cx-tools-mt-new-provider' ) )
+                               .addClass( 'card__providers-menu-item--new' );
+               }
+
+               return $( '<li>' )
+                       .append( $label, $new );
        };
 
        MTControlCard.prototype.start = function ( $section ) {
diff --git a/modules/tools/styles/ext.cx.tools.mt.less 
b/modules/tools/styles/ext.cx.tools.mt.less
index 010b208..0d79ed2 100644
--- a/modules/tools/styles/ext.cx.tools.mt.less
+++ b/modules/tools/styles/ext.cx.tools.mt.less
@@ -88,6 +88,12 @@
                        border-width: 11px;
                        margin-left: -11px;
                }
+
+               .card__providers-menu-item--new {
+                       padding-left: 10px;
+                       color: #00af89;
+                       font-size: 1em;
+               }
        }
 
        .card__button-block {
@@ -127,4 +133,22 @@
                        float: none;
                }
        }
+
+       .card__title-row.card--new::before {
+               content: "";
+               width: 0px;
+               height: 0px;
+               float: right;
+               border-top: 30px solid #00af89;
+               border-left: 30px solid transparent;
+               position: relative;
+               top: -10px;
+               left: 5px;
+       }
+
+       .card__title-row.card--new > .card__new-providers {
+               padding: 0 5px 5px 5px;
+               color: #00af89;
+               font-size: 1em;
+       }
 }

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I4bf8635a03ce21e334adbfdb9fffbb9963179699
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: wmf/1.27.0-wmf.16
Gerrit-Owner: KartikMistry <[email protected]>
Gerrit-Reviewer: Nikerabbit <[email protected]>
Gerrit-Reviewer: Santhosh <[email protected]>
Gerrit-Reviewer: Siebrand <[email protected]>
Gerrit-Reviewer: Thcipriani <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to