Files
2026-08-28 11:43:34 -04:00

46 lines
1.7 KiB
Python

# Python script: add i18n keys to both locale files
# Usage:
# cd /c/dev/git/python/obsigate
# python3 << 'PYEOF' ... PYEOF
#
# The script below adds new keys to both fr.json and en.json, keeping them
# alphabetically sorted. Adjust the `new_keys` dict as needed.
import json
with open('frontend/locales/fr.json', encoding='utf-8') as f:
fr = json.load(f)
with open('frontend/locales/en.json', encoding='utf-8') as f:
en = json.load(f)
# Keys to add: key -> {fr: "texte français", en: "english text"}
new_keys = {
"vaulthome.loading": {"fr": "Chargement des fichiers...", "en": "Loading files..."},
"vaulthome.empty": {"fr": "Aucun fichier dans ce repertoire", "en": "No files in this directory"},
"vaulthome.file_count": {"fr": "{count} fichier", "en": "{count} file"},
"vaulthome.file_count_plural": {"fr": "{count} fichiers", "en": "{count} files"},
"vaulthome.error_loading": {"fr": "Erreur de chargement:", "en": "Loading error:"},
"vaulthome.size_bytes": {"fr": "o", "en": "B"},
"vaulthome.size_kb": {"fr": "Ko", "en": "KB"},
"vaulthome.size_mb": {"fr": "Mo", "en": "MB"},
"common.root": {"fr": "(racine)", "en": "(root)"},
"common.unknown": {"fr": "Inconnue", "en": "Unknown"},
}
for k, v in new_keys.items():
fr[k] = v["fr"]
en[k] = v["en"]
fr = dict(sorted(fr.items()))
en = dict(sorted(en.items()))
with open('frontend/locales/fr.json', 'w', encoding='utf-8') as f:
json.dump(fr, f, ensure_ascii=False, indent=2)
f.write('\n')
with open('frontend/locales/en.json', 'w', encoding='utf-8') as f:
json.dump(en, f, ensure_ascii=False, indent=2)
f.write('\n')
print(f"OK: Added {len(new_keys)} keys. FR={len(fr)} EN={len(en)}")