Files
IKAR/tool/finalize_branding.py
T

23 lines
1.5 KiB
Python

from pathlib import Path
import re, json
root = Path(__file__).resolve().parents[1]
for area in ('lib', 'test', 'assets'):
for p in (root / area).rglob('*'):
if not p.is_file() or p.suffix not in ('.arb', '.dart', '.html', '.json'): continue
try: text = p.read_text(encoding='utf-8')
except UnicodeDecodeError: continue
updated = re.sub(r'\bQlyra\b', 'ИКАР', text)
updated = updated.replace('МАХ', 'ИКАР').replace('МАКС', 'ИКАР')
updated = updated.replace('assets/qlyra_icon.png', 'assets/ikar_icon.png').replace('assets/qlyra.png', 'assets/ikar.png')
if updated != text: p.write_text(updated, encoding='utf-8')
for locale in ('ru','en'):
p = root / f'lib/l10n/app_{locale}.arb'
data = json.loads(p.read_text(encoding='utf-8'))
# Authentication is provided by this server and the device signing key.
for key in list(data):
if key.startswith('@') or not isinstance(data[key], str): continue
value = data[key]
if '30 минут' in value or '30 minutes' in value:
data[key] = 'Вход подтверждается ключом устройства. Существующий аккаунт открывается на привязанном устройстве.' if locale == 'ru' else 'Sign-in is confirmed by your device key. An existing account requires a linked device.'
p.write_text(json.dumps(data, ensure_ascii=False, indent=2)+'\n', encoding='utf-8')