~ubuntu-branches/ubuntu/natty/moin/natty-updates

« back to all changes in this revision

Viewing changes to MoinMoin/macro/GetText2.py

  • Committer: Bazaar Package Importer
  • Author(s): Jonas Smedegaard
  • Date: 2008-06-22 21:17:13 UTC
  • mto: This revision was merged to the branch mainline in revision 18.
  • Revision ID: james.westby@ubuntu.com-20080622211713-inlv5k4eifxckelr
ImportĀ upstreamĀ versionĀ 1.7.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
    This macro has the main purpose of being used by extensions that write
6
6
    data to wiki pages but want to ensure that it is properly translated.
7
7
 
8
 
    @copyright: 2006 MoinMoin:AlexanderSchremmer,
9
 
                2009 MoinMoin:EugeneSyromyatnikov,
10
 
                2009 MoinMoin:ThomasWaldmann
 
8
    @copyright: 2006 MoinMoin:AlexanderSchremmer
11
9
    @license: GNU GPL, see COPYING for details.
12
10
"""
13
11
 
21
19
    and the remaining elements are substituted in the message using string
22
20
    substitution.
23
21
    """
24
 
    msg = u''
 
22
    sep = args[0]
 
23
    args = unpackLine(args[1:], sep)
25
24
    if args:
26
 
        sep = args[0]
27
 
        args = unpackLine(args[1:], sep)
28
 
        if args:
29
 
            msg, args = args[0], tuple(args[1:])
30
 
            msg = macro.request.getText(msg)
31
 
            try:
32
 
                msg = msg % args
33
 
            except TypeError:
34
 
                # % operator will raise TypeError if msg has named placeholders
35
 
                msg = msg % dict([arg.split('=', 1) for arg in args if '=' in arg])
36
 
    return macro.formatter.text(msg)
 
25
        translation = macro.request.getText(args[0])
 
26
    else:
 
27
        translation = u""
 
28
    message = translation % tuple(args[1:])
 
29
 
 
30
    return macro.formatter.text(message)
37
31