Spaces:
Sleeping
Sleeping
""" | |
utils_lang.py | |
Step 5/6: Language helpers for EN / FR / Kreol Morisien (MFE). | |
""" | |
from typing import Dict | |
SUPPORTED = { | |
"en": "English", | |
"fr": "Français", | |
"mfe": "Kreol Morisien", | |
} | |
def normalize_lang(code: str) -> str: | |
return code if code in SUPPORTED else "en" | |
_STRINGS: Dict[str, Dict[str, str]] = { | |
"en": { | |
"title": "Evo Government Copilot (Mauritius)", | |
"ask_placeholder": "e.g., How do I renew my Mauritius passport?", | |
"ask_label": "Your question", | |
"k_label": "Context depth (top-k)", | |
"build_btn": "🔧 Build/Refresh Index (TXT)", | |
"status_idle": "Status: _idle_", | |
"intro_ok": "Answer (grounded in retrieved sources):", | |
"intro_err": "I couldn’t find enough information. Try rephrasing or add official documents.", | |
"sources": "Sources", | |
"links": "Official links", | |
"forms": "Forms", | |
"tip_build": "Tip: Click 'Build/Refresh Index' first.", | |
}, | |
"fr": { | |
"title": "Copilote Gouvernemental Evo (Maurice)", | |
"ask_placeholder": "ex. Comment puis-je renouveler mon passeport mauricien ?", | |
"ask_label": "Votre question", | |
"k_label": "Profondeur du contexte (top-k)", | |
"build_btn": "🔧 Construire/Actualiser l’index (TXT)", | |
"status_idle": "Statut : _inactif_", | |
"intro_ok": "Réponse (fondée sur les sources récupérées) :", | |
"intro_err": "Je n’ai pas trouvé assez d’informations. Reformulez ou ajoutez des documents officiels.", | |
"sources": "Sources", | |
"links": "Liens officiels", | |
"forms": "Formulaires", | |
"tip_build": "Astuce : cliquez d’abord sur « Construire/Actualiser l’index ».", | |
}, | |
"mfe": { | |
"title": "Evo Gouv Copilot (Morisi)", | |
"ask_placeholder": "eg. Kouma mo kapav renouvle mo paspor Morisien?", | |
"ask_label": "To kestyon", | |
"k_label": "Profonder konteks (top-k)", | |
"build_btn": "🔧 Bati/Rafresir Index (TXT)", | |
"status_idle": "Sta: _repoze_", | |
"intro_ok": "Repons (lor sours ki finn gagne):", | |
"intro_err": "Pena ase informasion. Esay rephrase ouswa azout dokiman ofisiel.", | |
"sources": "Sours", | |
"links": "Lyen ofisiel", | |
"forms": "Formiler", | |
"tip_build": "Tip: Klik « Bati/Rafresir Index » avan.", | |
}, | |
} | |
def L(lang: str, key: str) -> str: | |
lang = normalize_lang(lang) | |
if key in _STRINGS.get(lang, {}): | |
return _STRINGS[lang][key] | |
return _STRINGS["en"].get(key, key) | |