downthemall/util/makelocalelist.py
2020-08-29 19:56:05 +02:00

16 lines
525 B
Python
Executable File
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env python3
import json
from pathlib import Path
langs = sorted(Path("_locales").glob("**/messages.json"), key=lambda p: p.parent.name.casefold())
all = {}
for m in langs:
loc = m.parent.name
with m.open("r", encoding="utf-8") as mp:
lang = json.load(mp).get("language").get("message")
if not lang:
raise Exception(f"{m}: no language")
lang = f"{lang} [{loc}]"
all[loc] = lang
with open("_locales/all.json", "wb") as op:
op.write(json.dumps(all, indent=2, ensure_ascii=False).encode("utf-8"))