File size: 2,533 Bytes
fe75261
 
6da249d
fe75261
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6da249d
 
fe75261
 
 
 
 
 
 
 
 
 
 
 
6da249d
 
fe75261
 
 
 
 
 
 
 
 
 
 
 
6da249d
 
fe75261
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
"""
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)