From b805e2fa78212600c7369d846c779e2125194909 Mon Sep 17 00:00:00 2001 From: Reinder Feenstra Date: Sun, 28 May 2023 00:24:37 +0200 Subject: [PATCH] translation: added script for converting to JSON for poeditor.com import --- utils/locale2json.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 utils/locale2json.py diff --git a/utils/locale2json.py b/utils/locale2json.py new file mode 100644 index 00000000..ef3f1334 --- /dev/null +++ b/utils/locale2json.py @@ -0,0 +1,20 @@ +import sys +import os +import json +import codecs +from traintastic import read_locale_file + + +def to_json(filename_txt, filename_json): + (strings, header, garbage) = read_locale_file(filename_txt) + out = [] + for s in strings: + if not s['hash']: + out.append({'term': s['id'], 'definition': s['value']}) + with codecs.open(filename_json, 'w', 'utf-8') as f: + json.dump(out, f, indent=' ') + + +if __name__ == "__main__": + for f in sys.argv[1:]: + to_json(f, os.path.splitext(f)[0] + '.json')