Gerrit Patch Uploader has uploaded a new change for review.

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

Change subject: Substitute messages in comment
......................................................................

Substitute messages in comment

Bug: 67068
Change-Id: Ifc380ede82092a6d5505a6b5fc00a1ab4480c98f
---
M includes/Linker.php
1 file changed, 23 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/41/141941/1

diff --git a/includes/Linker.php b/includes/Linker.php
index 7d88f25..bd71f65 100644
--- a/includes/Linker.php
+++ b/includes/Linker.php
@@ -1309,6 +1309,9 @@
                # Allow HTML entities (for bug 13815)
                $comment = Sanitizer::escapeHtmlAllowEntities( $comment );
 
+               # Substitute messages:
+               $comment = self::substituteMessagesInComment( $comment );
+
                # Render autocomments and make links:
                $comment = self::formatAutocomments( $comment, $title, $local );
                $comment = self::formatLinksInComment( $comment, $title, $local 
);
@@ -1318,6 +1321,26 @@
        }
 
        /**
+        * Substitute messages in comment
+        *
+        * @param string $comment Text containing messages
+        * @return string
+        */
+       public static function substituteMessagesInComment( $comment ) {
+               return preg_replace_callback(
+                       '/
+                               \{\{int:
+                               ([^\}|]+) # 1. message; message names cannot 
include } or |
+                               \}\}
+                       /xi',
+                       function ( $match ) {
+                               return wfMessage( $match[1] )->escaped();
+                       },
+                       $comment
+               );
+       }
+
+       /**
         * Converts autogenerated comments in edit summaries into section links.
         * The pattern for autogen comments is / * foo * /, which makes for
         * some nasty regex.

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifc380ede82092a6d5505a6b5fc00a1ab4480c98f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Gerrit Patch Uploader <[email protected]>
Gerrit-Reviewer: Gerrit Patch Uploader <[email protected]>

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

Reply via email to