From 4902635a604a4cc724e72049431f2402af385836 Mon Sep 17 00:00:00 2001 From: Yuri Chornoivan Date: Sat, 9 Jan 2021 10:33:56 +0200 Subject: Fix the script to obtain the valid JSON --- plasma_json/po2json.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'plasma_json/po2json.py') diff --git a/plasma_json/po2json.py b/plasma_json/po2json.py index 1740a044..98319557 100755 --- a/plasma_json/po2json.py +++ b/plasma_json/po2json.py @@ -111,8 +111,11 @@ for langfile in files: for entry in po.translated_entries(): for line in lines: if entry.msgid in line: - indent = line.replace('\"' + entry.msgctxt + '\": \"' + entry.msgid + '\",', '') - origandtranslated = line + '\n' + indent + '\"' + entry.msgctxt + '[' + lang + ']' + '\": \"' + entry.msgstr + '\",' + 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 + '\",' text = text.replace(line, origandtranslated) jsonfile.write(text) -- cgit v1.2.1