22 lines
662 B
Python
22 lines
662 B
Python
"""One-time export: convert i18n.py translations to JSON files."""
|
|
import json
|
|
from pathlib import Path
|
|
|
|
from app.i18n import _translations
|
|
|
|
locales_dir = Path(__file__).resolve().parent / "app" / "locales"
|
|
locales_dir.mkdir(exist_ok=True)
|
|
|
|
langs: dict[str, dict[str, str]] = {}
|
|
for key, values in _translations.items():
|
|
for lang, text in values.items():
|
|
langs.setdefault(lang, {})[key] = text
|
|
|
|
for lang, data in sorted(langs.items()):
|
|
out = locales_dir / f"{lang}.json"
|
|
with open(out, "w", encoding="utf-8") as f:
|
|
json.dump(data, f, ensure_ascii=False, indent=2)
|
|
print(f"Exported {len(data)} keys -> {out.name}")
|
|
|
|
print("Done!")
|