/usr/share/unity-webapps/tools/po2json.py is in unity-webapps-dev 2.4.17+14.04.20140416-0ubuntu1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | #!/usr/bin/python3
from urllib.parse import quote
from glob import glob
from json import dumps
from polib import pofile
from sys import argv
result = {}
for filename in glob('po/*.po'):
po = pofile(filename,
autodetect_encoding=False,
encoding='utf-8',
wrapwidth=-1)
t = {}
for entry in po:
if entry.obsolete or entry.msgstr in ('', entry.msgid):
continue
t[entry.msgid] = entry.msgstr
lang = filename[3:-3] # 'po/lang.po' -> 'lang'
result[lang] = t
if '--debug' in argv:
from pprint import pprint
pprint(result)
else:
print(quote(dumps(result, sort_keys=True)))
|