aboutsummaryrefslogtreecommitdiffstats
path: root/plasma_json
diff options
context:
space:
mode:
authorYuri Chornoivan <yurchor@ukr.net>2021-01-09 10:33:56 +0200
committerYuri Chornoivan <yurchor@ukr.net>2021-01-09 10:33:56 +0200
commit4902635a604a4cc724e72049431f2402af385836 (patch)
tree5c49c10779ce1b1e58317a1059b957946bf7594f /plasma_json
parent85005babd41f20fefae33147f708a1167c0d7f80 (diff)
downloadtools-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
Diffstat (limited to 'plasma_json')
-rw-r--r--plasma_json/po/json.pot2
-rwxr-xr-xplasma_json/po2json.py7
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)