1
0
Fork 0
mirror of https://github.com/YunoHost/apps.git synced 2024-09-03 20:06:07 +02:00

[enh] allow generate_translation_file to take several jsons

This commit is contained in:
Laurent Peuch 2017-03-07 01:05:08 +01:00
parent 6bfee7b4da
commit da693cc6bc

View file

@ -9,39 +9,46 @@ if __name__ == '__main__':
print "Abort" print "Abort"
sys.exit(1) sys.exit(1)
builded_file = json.load(open(sys.argv[1], "r"))
other_langs = {} other_langs = {}
keys = [] keys = []
en = {} en = {}
for app, data in builded_file.items(): for builded_file in sys.argv[1:]:
key = "%s_manifest_description" % app builded_file = json.load(open(builded_file, "r"))
en[key] = data["manifest"]["description"]["en"]
keys.append(key)
for i in data["manifest"]["description"]: for app, data in builded_file.items():
if i not in other_langs: if "en" not in data["manifest"]["description"]:
other_langs[i] = {x: "" for x in keys} continue
for i, translations in other_langs.items(): key = "%s_manifest_description" % app
translations[key] = data["manifest"]["description"].get(i, "") en[key] = data["manifest"]["description"]["en"]
keys.append(key)
for category, questions in data["manifest"]["arguments"].items(): for i in data["manifest"]["description"]:
for question in questions: if i not in other_langs:
key = "%s_manifest_arguments_%s_%s" % (app, category, question["name"]) other_langs[i] = {x: "" for x in keys}
en[key] = question["ask"]["en"]
keys.append(key) for i, translations in other_langs.items():
translations[key] = data["manifest"]["description"].get(i, "")
for i in question["ask"]: for category, questions in data["manifest"]["arguments"].items():
if i not in other_langs: for question in questions:
other_langs[i] = {x: "" for x in keys} if "en" not in question["ask"]:
continue
for i, translations in other_langs.items(): key = "%s_manifest_arguments_%s_%s" % (app, category, question["name"])
translations[key] = question["ask"].get(i, "") en[key] = question["ask"]["en"]
keys.append(key)
for i in question["ask"]:
if i not in other_langs:
other_langs[i] = {x: "" for x in keys}
for i, translations in other_langs.items():
translations[key] = question["ask"].get(i, "")
if not os.path.exists("locales"): if not os.path.exists("locales"):
os.makedirs("locales") os.makedirs("locales")