aboutsummaryrefslogtreecommitdiffstats
path: root/plasma_json/po2json.py
diff options
context:
space:
mode:
authorYuri Chornoivan <yurchor@ukr.net>2021-01-09 12:47:37 +0200
committerYuri Chornoivan <yurchor@ukr.net>2021-01-09 12:47:37 +0200
commitc2df9e5408c172f0fc562bf3bde78382f9a0d7e3 (patch)
tree62e3d3c14b021b4d792160dd64d145c998ccf75c /plasma_json/po2json.py
parent0383ec743e479716f104688575c42e13ce964c0f (diff)
downloadtools-c2df9e5408c172f0fc562bf3bde78382f9a0d7e3.tar
tools-c2df9e5408c172f0fc562bf3bde78382f9a0d7e3.tar.gz
tools-c2df9e5408c172f0fc562bf3bde78382f9a0d7e3.tar.bz2
tools-c2df9e5408c172f0fc562bf3bde78382f9a0d7e3.tar.xz
tools-c2df9e5408c172f0fc562bf3bde78382f9a0d7e3.zip
Fix the script once again
Diffstat (limited to 'plasma_json/po2json.py')
-rwxr-xr-xplasma_json/po2json.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/plasma_json/po2json.py b/plasma_json/po2json.py
index 98319557..3b375808 100755
--- a/plasma_json/po2json.py
+++ b/plasma_json/po2json.py
@@ -112,12 +112,15 @@ for langfile in files:
for line in lines:
if entry.msgid in line:
indent = line.replace('\"' + entry.msgctxt + '\": \"' + entry.msgid + '\"', '').strip(',')
- if '}' in lines[lines.index(line) + 1]:
- origandtranslated = line + '\n' + indent + '\"' + entry.msgctxt + '[' + lang + ']' + '\": \"' + entry.msgstr + '\"'
- else:
- origandtranslated = line + '\n' + indent + '\"' + entry.msgctxt + '[' + lang + ']' + '\": \"' + entry.msgstr + '\",'
+ origandtranslated = line + '\n' + indent + '\"' + entry.msgctxt + '[' + lang + ']' + '\": \"' + entry.msgstr + '\",'
text = text.replace(line, origandtranslated)
+ # Remove extra commas
+ lines = text.split('\n')
+ for line in lines:
+ if (line.endswith(',')) and ('}' in lines[lines.index(line) + 1]):
+ text = text.replace(line, line[:-1])
+
jsonfile.write(text)
jsonfile.close()