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

Change subject: Add checker and suggester for Blockly.
......................................................................


Add checker and suggester for Blockly.

Change-Id: Ie7773a4b67507433936a5819ff6bfd1fe41788ea
---
M groups/Blockly/Blockly.yaml
A groups/Blockly/Checker.php
A groups/Blockly/Suggester.php
3 files changed, 47 insertions(+), 0 deletions(-)

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



diff --git a/groups/Blockly/Blockly.yaml b/groups/Blockly/Blockly.yaml
index 806a185..3eb2440 100644
--- a/groups/Blockly/Blockly.yaml
+++ b/groups/Blockly/Blockly.yaml
@@ -11,6 +11,18 @@
       sr-ec: sr
       sr-el: sr-latn
 
+  CHECKER:
+    class: BlocklyMessageChecker
+    checks:
+      - variablesCheck
+
+  INSERTABLES:
+    class: BlocklySuggester
+
+  AUTOLOAD:
+    BlocklyMessageChecker: Checker.php
+    BlocklySuggester: Suggester.php
+
 ---
 BASIC:
   id: out-blockly-0-all
diff --git a/groups/Blockly/Checker.php b/groups/Blockly/Checker.php
new file mode 100644
index 0000000..750e098
--- /dev/null
+++ b/groups/Blockly/Checker.php
@@ -0,0 +1,12 @@
+<?php
+/**
+ * @file
+ * @license GPL-2.0+
+ */
+
+class BlocklyMessageChecker extends MessageChecker {
+       protected function variablesCheck( $messages, $code, &$warnings ) {
+               // %1, %2, .., %9
+               return parent::parameterCheck( $messages, $code, $warnings, 
'/%[1-9]/' );
+       }
+}
diff --git a/groups/Blockly/Suggester.php b/groups/Blockly/Suggester.php
new file mode 100644
index 0000000..3a43f08
--- /dev/null
+++ b/groups/Blockly/Suggester.php
@@ -0,0 +1,23 @@
+<?php
+/**
+ * @file
+ * @author Niklas Laxström
+ * @author Siebrand Mazeland
+ * @license GPL-2.0+
+ */
+
+class BlocklySuggester {
+       public function getInsertables( $text ) {
+               $insertables = array();
+
+               $matches = array();
+               // %1, %2, .., %9
+               preg_match_all( '/%[1-9]+/', $text, $matches, PREG_SET_ORDER );
+               $new = array_map( function( $match ) {
+                       return new Insertable( $match[0], $match[0] );
+               }, $matches );
+               $insertables = array_merge( $insertables, $new );
+
+               return $insertables;
+       }
+}

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ie7773a4b67507433936a5819ff6bfd1fe41788ea
Gerrit-PatchSet: 2
Gerrit-Project: translatewiki
Gerrit-Branch: master
Gerrit-Owner: Siebrand <[email protected]>
Gerrit-Reviewer: Nikerabbit <[email protected]>
Gerrit-Reviewer: Siebrand <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to