50 lines
1.3 KiB
Python
50 lines
1.3 KiB
Python
# i18n Audit Scripts
|
|
|
|
Helper Python scripts for auditing ObsiGate i18n coverage.
|
|
|
|
## audit_french_in_html.py
|
|
|
|
Scans index.html for French text without data-i18n:
|
|
|
|
```python
|
|
from pathlib import Path
|
|
import re
|
|
|
|
html = Path("frontend/index.html").read_text(encoding="utf-8")
|
|
lines = html.split("\n")
|
|
|
|
for i, line in enumerate(lines, 1):
|
|
if 'data-i18n' in line:
|
|
continue
|
|
# Find text between tags with French chars
|
|
texts = re.findall(r'>([^<>{}\n]{4,80})<', line)
|
|
for t in texts:
|
|
if any(c in t for c in 'éèêëàâùûôîïçÉÈÊËÀ'):
|
|
print(f"L{i}: {t.strip()[:120]}")
|
|
```
|
|
|
|
## audit_en_fr_mismatch.py
|
|
|
|
Finds untranslated keys (EN == FR) and French chars in EN values:
|
|
|
|
```python
|
|
import json
|
|
|
|
en = json.load(open("frontend/locales/en.json"))
|
|
fr = json.load(open("frontend/locales/fr.json"))
|
|
|
|
identical = []
|
|
french_in_en = []
|
|
|
|
for k in en:
|
|
ev = en[k]; fv = fr.get(k, "")
|
|
if isinstance(ev, str) and isinstance(fv, str):
|
|
if ev == fv and len(ev) > 3 and not ev.startswith('<'):
|
|
identical.append((k, ev))
|
|
if any(c in ev for c in 'éèêëàâùûôîïçÉÈÊËÀ'):
|
|
french_in_en.append((k, ev))
|
|
|
|
print(f"Identical EN=FR: {len(identical)}")
|
|
print(f"French chars in EN: {len(french_in_en)}")
|
|
```
|