~ubuntu-branches/ubuntu/oneiric/moin/oneiric-security

« back to all changes in this revision

Viewing changes to MoinMoin/macro/GetText2.py

  • Committer: Bazaar Package Importer
  • Author(s): Jamie Strandboge
  • Date: 2010-03-30 12:55:34 UTC
  • mfrom: (0.1.17 sid)
  • Revision ID: james.westby@ubuntu.com-20100330125534-4c2ufc1rok24447l
Tags: 1.9.2-2ubuntu1
* Merge from Debian testing (LP: #521834). Based on work by Stefan Ebner.
  Remaining changes:
 - Remove python-xml from Suggests field, the package isn't anymore in
   sys.path.
 - Demote fckeditor from Recommends to Suggests; the code was previously
   embedded in moin, but it was also disabled, so there's no reason for us
   to pull this in by default currently. Note: This isn't necessary anymore
   but needs a MIR for fckeditor, so postpone dropping this change until
   lucid+1
* debian/rules:
  - Replace hardcoded python2.5 with python* and hardcore python2.6 for ln
* debian/control.in: drop versioned depends on cdbs

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
 
8
    @copyright: 2006 MoinMoin:AlexanderSchremmer,
 
9
                2009 MoinMoin:EugeneSyromyatnikov,
 
10
                2009 MoinMoin:ThomasWaldmann
9
11
    @license: GNU GPL, see COPYING for details.
10
12
"""
11
13
 
19
21
    and the remaining elements are substituted in the message using string
20
22
    substitution.
21
23
    """
22
 
    sep = args[0]
23
 
    args = unpackLine(args[1:], sep)
 
24
    msg = u''
24
25
    if args:
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)
 
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)
31
37