Created
February 1, 2019 11:38
-
-
Save maxpeterson/2ce12c2d43f7a68c4ffa21584c0de7c3 to your computer and use it in GitHub Desktop.
Revisions
-
maxpeterson created this gist
Feb 1, 2019 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,33 @@ #!/usr/bin/env python # -*- python -*- # Usage: python fake_translate.py inputfile.po outputfile.po import re import sys import polib # handle leading whitespace start = re.compile('^(\s*)') end = re.compile('(\s*)$') def fake(msgid): """Generate a fake translation for the msgid""" return end.sub('**\g<1>', start.sub('\g<1>**', msgid)) po = polib.pofile(sys.argv[1]) for entry in po: if entry.msgid_plural: entry.msgstr_plural = { 0: fake(entry.msgid), 1: fake(entry.msgid_plural), } elif entry.msgid: entry.msgstr = fake(entry.msgid) po.save(sys.argv[2])