Siebrand has uploaded a new change for review.

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

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, 49 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/translatewiki 
refs/changes/15/271015/1

diff --git a/groups/Blockly/Blockly.yaml b/groups/Blockly/Blockly.yaml
index 806a185..f3ec8a3 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:
+      - BlocklyVariablesCheck
+
+  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..b13a854
--- /dev/null
+++ b/groups/Blockly/Checker.php
@@ -0,0 +1,14 @@
+<?php
+/**
+ * @file
+ * @author Niklas Laxström
+ * @author Siebrand Mazeland
+ * @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..43713ad
--- /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: newchange
Gerrit-Change-Id: Ie7773a4b67507433936a5819ff6bfd1fe41788ea
Gerrit-PatchSet: 1
Gerrit-Project: translatewiki
Gerrit-Branch: master
Gerrit-Owner: Siebrand <[email protected]>

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

Reply via email to