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

Change subject: Add a link to Magnus's "Not in the other language" tool
......................................................................


Add a link to Magnus's "Not in the other language" tool

Introduces $wgContentTranslationUseMagnusTool boolean
configuration to enable or disable it.
By default it is enabled.

This is attached to dashboard by newly introduced
'mw.cx.dashboard.ready' hook

Bug: T76843
Change-Id: I68aee04d3942b0bd5030cc83fa973ce344b4e44b
---
M ContentTranslation.php
M Resources.php
M hooks.md
M i18n/en.json
M i18n/qqq.json
M modules/dashboard/ext.cx.dashboard.js
A modules/dashboard/ext.cx.magnuslink.js
A modules/dashboard/styles/ext.cx.magnuslink.less
M specials/SpecialContentTranslation.php
9 files changed, 114 insertions(+), 0 deletions(-)

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



diff --git a/ContentTranslation.php b/ContentTranslation.php
index 8065689..386e5a4 100644
--- a/ContentTranslation.php
+++ b/ContentTranslation.php
@@ -146,6 +146,14 @@
 // List of campaigns enabled. Available campaigns: 'newarticle'
 $GLOBALS['wgContentTranslationCampaigns'] = array();
 
+/*
+ * Whether the Magnus tool to find missing articles to be enabled or not.
+ * This is initially made to experiment with an article comparison tool at
+ * http://tools.wmflabs.org/not-in-the-other-language/
+ * See https://phabricator.wikimedia.org/T76843
+ */
+$GLOBALS['wgContentTranslationUseMagnusTool'] = true;
+
 // List of browsers Content Translation is incompatibe with
 // See jQuery.client for specification
 $GLOBALS['wgContentTranslationBrowserBlacklist'] = array(
diff --git a/Resources.php b/Resources.php
index 0d1f7f0..62471f8 100644
--- a/Resources.php
+++ b/Resources.php
@@ -93,6 +93,7 @@
                'ext.cx.source.selector',
                'ext.cx.feedback',
                'mediawiki.ui.button',
+               'mediawiki.Uri',
        ),
        'messages' => array(
                'cx-create-new-translation',
@@ -100,6 +101,18 @@
        ),
 ) + $resourcePaths;
 
+$wgResourceModules['ext.cx.magnuslink'] = array(
+       'scripts' => array(
+               'dashboard/ext.cx.magnuslink.js',
+       ),
+       'styles' => array(
+               'dashboard/styles/ext.cx.magnuslink.less',
+       ),
+       'messages' => array(
+               'cx-magnus-tool-link-text',
+       ),
+) + $resourcePaths;
+
 $wgResourceModules['ext.cx.util'] = array(
        'scripts' => array(
                'util/ext.cx.util.js',
diff --git a/hooks.md b/hooks.md
index d893b00..869cbd8 100644
--- a/hooks.md
+++ b/hooks.md
@@ -147,3 +147,7 @@
 ## mw.cx.translation.saved
 
 Fired after a translation was successfully saved as a draft.
+
+# mw.cx.dashboard.ready
+
+Fired when the Content Translation dashboard is ready.
diff --git a/i18n/en.json b/i18n/en.json
index 1878cd4..6a5be03 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -138,6 +138,7 @@
        "cx-translation-status-draft": "In progress",
        "cx-translation-status-published": "Published",
        "cx-translation-status-deleted": "Deleted",
+       "cx-magnus-tool-link-text": "Find articles missing in your language",
        "apihelp-cxdelete-description": "Delete a draft translation created 
using the Content Translation extension.",
        "apihelp-cxdelete-param-from": "The source language code.",
        "apihelp-cxdelete-param-to": "The target language code.",
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 4f13f6e..5427325 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -143,6 +143,7 @@
        "cx-translation-status-draft": "In progress status label for the 
translation in the Content Translation dashboard. This means that the 
translation is stored internally as a draft, accessible only to the user who 
started it, and not published as a wiki page.",
        "cx-translation-status-published": "Published status label for the 
translation in the Content Translation dashboard.\n{{Identical|Published}}",
        "cx-translation-status-deleted": "Deleted status label for the 
translation in the Content Translation dashboard.\n{{Identical|Deleted}}",
+       "cx-magnus-tool-link-text": "A link text. If this link appears, it 
links to the ''[http://tools.wmflabs.org/not-in-the-other-language/ Not in your 
language]'' tool in WMF Labs.",
        "apihelp-cxdelete-description": "{{doc-apihelp-description|cxdelete}}",
        "apihelp-cxdelete-param-from": "{{doc-apihelp-param|cxdelete|from}}",
        "apihelp-cxdelete-param-to": "{{doc-apihelp-param|cxdelete|to}}",
diff --git a/modules/dashboard/ext.cx.dashboard.js 
b/modules/dashboard/ext.cx.dashboard.js
index 436c252..0ef91a8 100644
--- a/modules/dashboard/ext.cx.dashboard.js
+++ b/modules/dashboard/ext.cx.dashboard.js
@@ -28,6 +28,7 @@
                this.render();
                this.initComponents();
                this.listen();
+               mw.hook( 'mw.cx.dashboard.ready' ).fire();
        };
 
        /**
@@ -43,6 +44,7 @@
 
                this.$header = $( '<div>' ).addClass( 'cx-widget__header' );
                $newTranslationContainer = $( '<div>' ).addClass( 'cx-cta' );
+
                this.$translationList = $( '<div>' ).addClass( 
'cx-translationlist' );
                $content = $( '<div>' ).addClass( 'cx-widget' )
                        .append( this.$header, $newTranslationContainer, 
this.$translationList );
@@ -56,6 +58,7 @@
                        .html( mw.message( 'cx-create-new-translation-desc' 
).parse() );
 
                $newTranslationContainer.append( this.$newTranslationButton, 
$newTranslationDesc );
+
                this.$container.cxFeedback();
        };
 
diff --git a/modules/dashboard/ext.cx.magnuslink.js 
b/modules/dashboard/ext.cx.magnuslink.js
new file mode 100644
index 0000000..c7b6fed
--- /dev/null
+++ b/modules/dashboard/ext.cx.magnuslink.js
@@ -0,0 +1,64 @@
+/**
+ * A link from ContentTranslation dashboard to Magnus Manske's
+ * tool for finding missing articles.
+ *
+ * @file
+ * @ingroup Extensions
+ * @copyright See AUTHORS.txt
+ * @license GPL-2.0+
+ */
+( function ( $, mw ) {
+       'use strict';
+
+       var toolLink = 'https://tools.wmflabs.org/not-in-the-other-language/';
+
+       function getMagnusToolLink() {
+               var uri, contentLanguage, previousLanguages,
+                       sourceLanguage, targetLanguage, $link, $linkContainer;
+
+               uri = new mw.Uri( toolLink );
+
+               contentLanguage = mw.config.get( 'wgContentLanguage' );
+               previousLanguages = mw.uls.getPreviousLanguages();
+               sourceLanguage = mw.cx.sourceLanguage ||
+                       ( window.localStorage && localStorage.getItem( 
'cxSourceLanguage' ) ) ||
+                       previousLanguages[ previousLanguages.length - 1 ] ||
+                       ( contentLanguage === 'en' ? 'de' : 'en' );
+
+               targetLanguage = mw.cx.targetLanguage ||
+                       ( window.localStorage && localStorage.getItem( 
'cxTargetLanguage' ) ) ||
+                       contentLanguage;
+
+               uri.extend( {
+                       lang1: sourceLanguage,
+                       lang2: targetLanguage
+               } );
+
+               // The algorithm for guessing the source and target languages 
is very basic
+               // and can return invalid results.
+               // Run the actual query ("doit"), only if the languages
+               // are defined and not identical, otherwise the query will 
appear to be stuck.
+               if ( sourceLanguage !== targetLanguage ) {
+                       uri.extend( {
+                               doit: 'Do it'
+                       } );
+               }
+
+               $link = $( '<a>' )
+                       .text( mw.msg( 'cx-magnus-tool-link-text' ) )
+                       .prop( {
+                               target: '_blank',
+                               href: uri.toString()
+                       } );
+
+               $linkContainer = $( '<div>' )
+                       .addClass( 'cx-magnus-link' )
+                       .append( $link );
+
+               return $linkContainer;
+       }
+
+       mw.hook( 'mw.cx.dashboard.ready' ).add( function () {
+               $( '.cx-cta' ).append( getMagnusToolLink() );
+       } );
+}( jQuery, mediaWiki ) );
diff --git a/modules/dashboard/styles/ext.cx.magnuslink.less 
b/modules/dashboard/styles/ext.cx.magnuslink.less
new file mode 100644
index 0000000..f521641
--- /dev/null
+++ b/modules/dashboard/styles/ext.cx.magnuslink.less
@@ -0,0 +1,15 @@
+@import "../../base/styles/grid/agora-grid";
+@import "mediawiki.mixins";
+
+.cx-magnus-link {
+       .mw-ui-item;
+       .mw-ui-one-whole;
+
+       font-size: 18px;
+       line-height: 22px;
+       padding-top: 20px;
+
+       a {
+               text-decoration: none;
+       }
+}
diff --git a/specials/SpecialContentTranslation.php 
b/specials/SpecialContentTranslation.php
index 892936d..5163566 100644
--- a/specials/SpecialContentTranslation.php
+++ b/specials/SpecialContentTranslation.php
@@ -66,6 +66,8 @@
        }
 
        public function execute( $parameters ) {
+               global $wgContentTranslationUseMagnusTool;
+
                $out = $this->getOutput();
                $skin = $this->getSkin();
                $request = $this->getRequest();
@@ -89,6 +91,9 @@
                        $out->addModules( 'ext.cx.translationview' );
                } else {
                        $out->addModules( 'ext.cx.dashboard' );
+                       if ( $wgContentTranslationUseMagnusTool ) {
+                               $out->addModules( 'ext.cx.magnuslink' );
+                       }
                }
 
                $this->setHeaders();

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I68aee04d3942b0bd5030cc83fa973ce344b4e44b
Gerrit-PatchSet: 9
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Amire80 <amir.ahar...@mail.huji.ac.il>
Gerrit-Reviewer: Amire80 <amir.ahar...@mail.huji.ac.il>
Gerrit-Reviewer: Nikerabbit <niklas.laxst...@gmail.com>
Gerrit-Reviewer: Santhosh <santhosh.thottin...@gmail.com>
Gerrit-Reviewer: Siebrand <siebr...@kitano.nl>
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