Skip to content

Instantly share code, notes, and snippets.

@heinrich5991
Created August 8, 2015 20:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save heinrich5991/6ee787b6fabe1ff6f728 to your computer and use it in GitHub Desktop.
Save heinrich5991/6ee787b6fabe1ff6f728 to your computer and use it in GitHub Desktop.
import polib
def reconvert(filename):
po = polib.pofile(open(filename, encoding='utf-8').read())
lines = []
for entry in po:
if entry.msgstr:
lines.append(entry.msgid)
lines.append("== " + entry.msgstr)
lines.append("")
with open(filename + '.txt', 'w', encoding='utf-8') as out:
out.write("\n".join(lines))
if __name__ == '__main__':
import sys
for filename in sys.argv[1:]:
reconvert(filename)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment