Files
proxycast/scripts/import_translations.py
T
budi 157db3fd78 fix: improve i18n translations and fix DOM replacement order
- Fixed 20 translation entries with concatenated words and incorrect formatting
- Fixed critical bug in DOM replacer that caused partial translations
- Sort translation patches by length (longest first) to prevent substring replacement issues
- Fixed TypeScript and ESLint errors
- Added comprehensive documentation of fixes
2026-01-08 04:32:05 +07:00

38 lines
1.1 KiB
Python

#!/usr/bin/env python3
"""Import translations from translations-remaining.json back to en.json"""
import json
from pathlib import Path
EN_FILE = Path(__file__).parent.parent / 'src' / 'i18n' / 'patches' / 'en.json'
INPUT_FILE = Path(__file__).parent.parent / 'translations-remaining.json'
if not INPUT_FILE.exists():
print(f"Error: {INPUT_FILE} not found")
print("Run extract_remaining_todos.py first")
exit(1)
print("Loading translations...")
with open(INPUT_FILE, 'r', encoding='utf-8') as f:
translations = json.load(f)
print("Loading en.json...")
with open(EN_FILE, 'r', encoding='utf-8') as f:
data = json.load(f)
# Apply translations
count = 0
for key, value in data.items():
if isinstance(value, str) and value.startswith('[TODO: Translate]'):
chinese = value.replace('[TODO: Translate] ', '')
if chinese in translations and translations[chinese]:
data[key] = translations[chinese]
count += 1
print(f"Applied {count} translations")
print("Saving en.json...")
with open(EN_FILE, 'w', encoding='utf-8') as f:
json.dump(data, f, ensure_ascii=False, indent=2)
print("Done!")