changeset 5274:c3b272d83749

merged moin/1.8
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Thu, 12 Nov 2009 12:53:25 +0100
parents a728d059c78e (current diff) d78c35783dd8 (diff)
children adb58cd3ece2
files
diffstat 1 files changed, 15 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/macro/GetText2.py	Mon Nov 09 03:09:29 2009 +0100
+++ b/MoinMoin/macro/GetText2.py	Thu Nov 12 12:53:25 2009 +0100
@@ -5,7 +5,9 @@
     This macro has the main purpose of being used by extensions that write
     data to wiki pages but want to ensure that it is properly translated.
 
-    @copyright: 2006 MoinMoin:AlexanderSchremmer
+    @copyright: 2006 MoinMoin:AlexanderSchremmer,
+                2009 MoinMoin:EugeneSyromyatnikov,
+                2009 MoinMoin:ThomasWaldmann
     @license: GNU GPL, see COPYING for details.
 """
 
@@ -19,13 +21,17 @@
     and the remaining elements are substituted in the message using string
     substitution.
     """
-    sep = args[0]
-    args = unpackLine(args[1:], sep)
+    msg = u''
     if args:
-        translation = macro.request.getText(args[0])
-    else:
-        translation = u""
-    message = translation % tuple(args[1:])
+        sep = args[0]
+        args = unpackLine(args[1:], sep)
+        if args:
+            msg, args = args[0], tuple(args[1:])
+            msg = macro.request.getText(msg)
+            try:
+                msg = msg % args
+            except TypeError:
+                # % operator will raise TypeError if msg has named placeholders
+                msg = msg % dict([arg.split('=', 1) for arg in args if '=' in arg])
+    return macro.formatter.text(msg)
 
-    return macro.formatter.text(message)
-