view MoinMoin/i18n/tools/markup15to16.py @ 2924:b551fc405222

use standard xx-yy for languages now (not xx_yy), fixes zh-tw issue (port from 1.6)
author Johannes Berg <johannes AT sipsolutions DOT net>
date Mon, 29 Oct 2007 10:01:12 +0100
parents d1a1f10a0451
children b1e7d968330d
line wrap: on
line source
#!/usr/bin/python
"""
    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, '../..')

    lang = sys.argv[1]

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

    # 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 = codecs.open("%s.%s.po" % (langfname, DOMAIN), "w", "utf-8")
    f.write(text)
    f.close()

if __name__ == "__main__":
    run()