MtDu has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/326179 )

Change subject: Support %1$s as insertable parameters in the MantisBT project
......................................................................

Support %1$s as insertable parameters in the MantisBT project

Bug: T150250
Change-Id: Ica2197ecb766e201e03c3014182aed562cd38d03
---
M groups/MantisBT/MantisBT.yaml
A groups/MantisBT/MantisBTInsertablesSuggester.php
2 files changed, 35 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/translatewiki 
refs/changes/79/326179/1

diff --git a/groups/MantisBT/MantisBT.yaml b/groups/MantisBT/MantisBT.yaml
index 4c24507..e273b8c 100644
--- a/groups/MantisBT/MantisBT.yaml
+++ b/groups/MantisBT/MantisBT.yaml
@@ -163,3 +163,9 @@
 
 FILES:
   sourcePattern: 
"%GROUPROOT%/mantis/plugins/XmlImportExport/lang/strings_%CODE%.txt"
+
+INSERTABLES:
+  class: MantisBTInsertablesSuggester
+
+AUTOLOAD:
+  MantisBTInsertablesSuggester: MantisBTInsertablesSuggester.php
diff --git a/groups/MantisBT/MantisBTInsertablesSuggester.php 
b/groups/MantisBT/MantisBTInsertablesSuggester.php
new file mode 100644
index 0000000..1fc4ba3
--- /dev/null
+++ b/groups/MantisBT/MantisBTInsertablesSuggester.php
@@ -0,0 +1,29 @@
+<?php
+/**
+ * Similar to Nocc/NoccInsertablesSuggester.php
+ *
+ * @file
+ * @author Justin Du
+ * @license GPL-2.0+
+ */
+
+class MantisBTInsertablesSuggester {
+       public function getInsertables( $text ) {
+               $insertables = [];
+
+               // %1$s
+               $matches = [];
+               preg_match_all(
+                       '/%\d\$s/',
+                       $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/326179
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ica2197ecb766e201e03c3014182aed562cd38d03
Gerrit-PatchSet: 1
Gerrit-Project: translatewiki
Gerrit-Branch: master
Gerrit-Owner: MtDu <justin.d...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to