view MoinMoin/i18n/tools/ @ 2768:d1a1f10a0451

po files: also find macros that are split at EOL
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 26 Aug 2007 14:14:54 +0200
parents 95a97b45a8e9
children b551fc405222
line wrap: on
line source

    convert some markup contained in po files to new link/macro markup
DOMAIN = "MoinMoin"

import re
import sys
import codecs

def run():
    sys.path.insert(0, '../..')

    langfname = sys.argv[1]
    lang = langfname.replace('_', '-') # module names use _ instead of -

    f ="%s.%s.po" % (langfname, DOMAIN), "r", "utf-8")
    text =

    # replace [[Macro(...)]] by <<Macro(...)>>
    macro_rule = r"\[\[(?P<macro>.*?)\]\]"
    macro_repl = r"<<\g<macro>>>"
    macro_re = re.compile(macro_rule, re.U|re.M|re.S)
    text = macro_re.sub(macro_repl, text)

    #print repr(text)

    f ="%s.%s.po" % (langfname, DOMAIN), "w", "utf-8")

if __name__ == "__main__":