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

Change subject: MT Abuse: Mark articles published with high MT
......................................................................


MT Abuse: Mark articles published with high MT

* Adds configuration option for adding a category to articles
  with a high amount of unedited MT on publishing
* Adjusts PHP publishing API to check for high MT and add category

Change-Id: I1b33d1f595d411e676f3cd8f42633e0d3b87d747
---
M ContentTranslation.php
M api/ApiContentTranslationPublish.php
2 files changed, 28 insertions(+), 0 deletions(-)

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



diff --git a/ContentTranslation.php b/ContentTranslation.php
index c0516f6..7f9fc50 100644
--- a/ContentTranslation.php
+++ b/ContentTranslation.php
@@ -108,6 +108,12 @@
 $GLOBALS['wgContentTranslationEventLogging'] = false;
 
 /**
+ * Category to add to published translations if there is a high amount
+ * of unedited machine translation. E.g., "Category:HighMT"
+ */
+$GLOBALS['wgContentTranslationHighMTCategory'] = null;
+
+/**
  * Patterns to access MediaWiki pages, APIs and cxserver in different languages
  * for the site family.
  */
diff --git a/api/ApiContentTranslationPublish.php 
b/api/ApiContentTranslationPublish.php
index 5b213ca..d43a990 100644
--- a/api/ApiContentTranslationPublish.php
+++ b/api/ApiContentTranslationPublish.php
@@ -44,6 +44,8 @@
        }
 
        protected function saveWikitext( $title, $wikitext, $params ) {
+               global $wgContentTranslationHighMTCategory;
+
                $sourceLink = '[[:' . $params['from']
                        . ':Special:Redirect/revision/'
                        . $params['sourcerevision']
@@ -53,6 +55,13 @@
                        $categories = explode( '|', $params['categories'] );
                        foreach ( $categories as $categoryTitle ) {
                                $wikitext .= "\n[[" . $categoryTitle . "]]";
+                       }
+               }
+
+               if ( $params['progress'] ) {
+                       $progress = json_decode( $params['progress'] );
+                       if ( $this->hasHighMT( $progress ) && 
$wgContentTranslationHighMTCategory ) {
+                               $wikitext .= "\n[[" . 
$wgContentTranslationHighMTCategory . ']]';
                        }
                }
 
@@ -246,4 +255,17 @@
                        /** @todo Provide examples */
                );
        }
+
+       /**
+        * Determines if the article is being published with a high amount of
+        * unedited MT content.
+        *
+        * @param StdObject progress
+        * @return boolean
+        */
+       protected function hasHighMT( $progress ) {
+               $mtPercentage =  $progress->any !== 0 ? $progress->mt / 
$progress->any * 100 : 0;
+               return $mtPercentage > 75 &&
+                       ( $progress->mtSectionsCount > 5 || $progress->any * 
100 > 75 );
+       }
 }

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I1b33d1f595d411e676f3cd8f42633e0d3b87d747
Gerrit-PatchSet: 5
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Jsahleen <[email protected]>
Gerrit-Reviewer: Jsahleen <[email protected]>
Gerrit-Reviewer: Santhosh <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to