view MoinMoin/i18n/tools/ @ 4133:251827af7ddc

Fixed: cannot check for File.Error in same line like checking import of File
author Florian Krupicka <>
date Tue, 27 May 2008 18:13:17 +0200
parents ed3c9a77bee2
children f976d490b9df
line wrap: on
line source
    remove everthing top of the first msgid line (PIs destroyed by gettext),
    prepend some processing instructions to a .po file to be able to put it
    onto moinmaster wiki, letting it get processed by gettext parser
def run():
    import sys, os, xmlrpclib
    sys.path.insert(0, '../..')

    excluded = ["en", ] # languages managed in repository, not in wiki

    lang = sys.argv[1]

    data =

    if lang in excluded:
        f = open("%s.MoinMoin.po" % lang, "w")

    data = data.decode('utf-8')

    cutpos = data.index(u"msgid")
    data = data[cutpos:] # remove comments at top

    data = u"""\
## Please edit system and help pages ONLY in the moinmaster wiki! For more
## information, please see MoinMaster:MoinPagesEditorGroup.
#acl MoinPagesEditorGroup:read,write,delete,revert All:read
#format gettext
#language %s

# MoinMoin %s system text translation
%s""" % (lang, lang, data)

    user = "ThomasWaldmann" # must be a known Wiki account
    password = os.environ.get("PASS", "")
    pagename = "MoinI18n/%s" % lang
    pagedata = data.encode('utf-8')

    wiki = xmlrpclib.ServerProxy("")
    token = wiki.getAuthToken(user, password)
    mc = xmlrpclib.MultiCall(wiki)
    mc.WhoAmI() # then we see in the result if auth worked correctly!
    mc.putPage(pagename, pagedata)
    result = mc()
    print "Page: %s rc=%r" % (pagename, list(result))

if __name__ == "__main__":