v0.1.0
This commit is contained in:
1 parent
cdca612a59
commit
eb25f8de4a
56 files changed
+7848
-4345
No files matched your search
Executable
+34
@@ -0,0 +1,34 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Build src/web/i18n/pl.json from scripts/i18n/pl_messages.py and report
|
||||
UI strings that have no Polish translation."""
|
||||
import json, re, sys
|
||||
from pathlib import Path
|
||||
|
||||
root = Path(__file__).resolve().parents[2]
|
||||
sys.path.insert(0, str(Path(__file__).parent))
|
||||
import pl_messages as pl # noqa: E402
|
||||
|
||||
src = "".join((root / "src/web/js" / f).read_text() for f in ("00-core.js", "10-pages.js"))
|
||||
keys = set(m.group(1).replace("\\'", "'") for m in re.finditer(r"\bte?\(\s*'((?:[^'\\]|\\.)*)'", src))
|
||||
for m in re.finditer(r"\['\w+', '([^']+)', '(Management|Services|Account|Mailbox)'", src):
|
||||
keys.update(m.groups())
|
||||
for m in re.finditer(r"(?:STATUS_LABELS|STATUS_HINTS|INTERVAL_LABELS) = \{([^}]*)\}", src):
|
||||
keys.update(re.findall(r":\s*'([^']+)'", m.group(1)))
|
||||
for m in re.finditer(r"(?:showToast\(|message: )'((?:[^'\\]|\\.)*)'", src):
|
||||
keys.add(m.group(1))
|
||||
|
||||
messages = {**pl.SERVER, **pl.UI}
|
||||
missing = sorted(k for k in keys if k not in messages)
|
||||
catalog = {
|
||||
"language": "pl",
|
||||
"messages": dict(sorted(messages.items())),
|
||||
"patterns": [{"match": m, "replace": r} for m, r in pl.PATTERNS],
|
||||
}
|
||||
(root / "src/web/i18n/pl.json").write_text(json.dumps(catalog, ensure_ascii=False, indent=1) + "\n")
|
||||
(root / "src/web/i18n/en.json").write_text(json.dumps({"language": "en", "messages": {}, "patterns": []}, indent=1) + "\n")
|
||||
print(f"pl.json: {len(messages)} messages, {len(pl.PATTERNS)} patterns")
|
||||
if missing:
|
||||
print("MISSING translations:")
|
||||
for k in missing:
|
||||
print(" ", k)
|
||||
sys.exit(1)
|
||||
Reference in new issue
Block a user