diff options
author | Yuri Chornoivan <yurchor@ukr.net> | 2021-01-09 10:33:56 +0200 |
---|---|---|
committer | Yuri Chornoivan <yurchor@ukr.net> | 2021-01-09 10:33:56 +0200 |
commit | 4902635a604a4cc724e72049431f2402af385836 (patch) | |
tree | 5c49c10779ce1b1e58317a1059b957946bf7594f | |
parent | 85005babd41f20fefae33147f708a1167c0d7f80 (diff) | |
download | tools-4902635a604a4cc724e72049431f2402af385836.tar tools-4902635a604a4cc724e72049431f2402af385836.tar.gz tools-4902635a604a4cc724e72049431f2402af385836.tar.bz2 tools-4902635a604a4cc724e72049431f2402af385836.tar.xz tools-4902635a604a4cc724e72049431f2402af385836.zip |
Fix the script to obtain the valid JSON
-rw-r--r-- | plasma_json/po/json.pot | 2 | ||||
-rwxr-xr-x | plasma_json/po2json.py | 7 |
2 files changed, 6 insertions, 3 deletions
diff --git a/plasma_json/po/json.pot b/plasma_json/po/json.pot index 5ab9dbea..b7363ab7 100644 --- a/plasma_json/po/json.pot +++ b/plasma_json/po/json.pot @@ -3,7 +3,7 @@ msgid "" msgstr "" "Project-Id-Version: Mageia json files translation\n" "Report-Msgid-Bugs-To: i18n-discuss@ml.mageia.org\n" -"POT-Creation-Date: 2021-01-09 09:41+0200\n" +"POT-Creation-Date: 2021-01-09 10:32+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" 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) |