Created
October 7, 2010 18:04
-
-
Save mpj/615555 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys, os, traceback, optparse | |
import polib | |
from xml.dom.minidom import Document | |
import time | |
import re | |
#from pexpect import run, spawn | |
def main (): | |
doc = Document() | |
i18n = doc.createElement("i18n") | |
doc.appendChild(i18n) | |
# load an existing po file | |
po = polib.pofile('russian.po') | |
for entry in po: | |
translation = doc.createElement("translation") | |
i18n.appendChild(translation) | |
key = doc.createElement("key") | |
translation.appendChild(key) | |
value = doc.createElement("value") | |
translation.appendChild(value) | |
key_text = doc.createTextNode(entry.msgctxt) | |
key.appendChild(key_text) | |
value_text = doc.createTextNode(entry.msgstr) | |
value.appendChild(value_text) | |
# Print our newly created XML | |
pretty_xml = doc.toprettyxml().encode('UTF-8') | |
handle = open("ru-pytte.xml", "wb") | |
handle.write(pretty_xml) | |
handle.close() | |
print "Done" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment