view MoinMoin/macro/GetText2.py @ 2999:e94b940f3a84

add a comment about listen backlog to moin.fcg (port from 1.6)
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 06 Jan 2008 17:32:33 +0100
parents bb2e053067fb
children 16ae95df840a
line wrap: on
line source
# -*- coding: iso-8859-1 -*-
"""
    MoinMoin - Load I18N Text and substitute data.

    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
    @license: GNU GPL, see COPYING for details.
"""

from MoinMoin.packages import unpackLine

Dependencies = ["language"]

def execute(macro, args):
    """ args consists of a character specifiying the separator and then a
    packLine sequence describing a list. The first element of it is the message
    and the remaining elements are substituted in the message using string
    substitution.
    """
    sep = args[0]
    args = unpackLine(args[1:], sep)
    if args:
        translation = macro.request.getText(args[0], formatted=False)
    else:
        translation = u""
    message = translation % tuple(args[1:])

    return macro.formatter.text(message)