chore: stage changes before history rewrite
This commit is contained in:
21
export_i18n.py
Normal file
21
export_i18n.py
Normal file
@@ -0,0 +1,21 @@
|
||||
"""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!")
|
||||
Reference in New Issue
Block a user