36 lines
1.1 KiB
Python
36 lines
1.1 KiB
Python
"""strings.json and translations/en.json must be identical; de.json must have the same keys."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import json
|
|
from pathlib import Path
|
|
import sys
|
|
|
|
BASE = Path(__file__).parents[1] / "custom_components" / "ninlight"
|
|
|
|
|
|
def keys(data: dict, prefix: str = "") -> set[str]:
|
|
out: set[str] = set()
|
|
for key, value in data.items():
|
|
out |= keys(value, f"{prefix}{key}.") if isinstance(value, dict) else {f"{prefix}{key}"}
|
|
return out
|
|
|
|
|
|
def main() -> int:
|
|
strings = json.loads((BASE / "strings.json").read_text(encoding="utf-8"))
|
|
en = json.loads((BASE / "translations" / "en.json").read_text(encoding="utf-8"))
|
|
de = json.loads((BASE / "translations" / "de.json").read_text(encoding="utf-8"))
|
|
if strings != en:
|
|
print("translations/en.json weicht von strings.json ab")
|
|
return 1
|
|
diff = sorted(keys(strings) ^ keys(de))
|
|
if diff:
|
|
print("de.json und strings.json haben unterschiedliche Schluessel:", diff)
|
|
return 1
|
|
print("Uebersetzungen vollstaendig")
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|