HemanM commited on
Commit
6da249d
·
verified ·
1 Parent(s): 57774c2

Update utils_lang.py

Browse files
Files changed (1) hide show
  1. utils_lang.py +7 -15
utils_lang.py CHANGED
@@ -1,18 +1,10 @@
1
  """
2
  utils_lang.py
3
- Step 5: Language helpers for EN / FR / Kreol Morisien (MFE).
4
-
5
- (Objective)
6
- - We provide a tiny, dependency-free way to localize the UI labels and
7
- fixed phrases. Content retrieved from your docs stays as-is; we only
8
- translate the "glue text" we control.
9
-
10
- - You can add more phrases later in one place.
11
  """
12
 
13
  from typing import Dict
14
 
15
- # Supported language codes and display names (Objective)
16
  SUPPORTED = {
17
  "en": "English",
18
  "fr": "Français",
@@ -20,11 +12,8 @@ SUPPORTED = {
20
  }
21
 
22
  def normalize_lang(code: str) -> str:
23
- """(Objective) Ensure a valid code; default to English."""
24
  return code if code in SUPPORTED else "en"
25
 
26
-
27
- # Minimal localized strings used by the app (Objective)
28
  _STRINGS: Dict[str, Dict[str, str]] = {
29
  "en": {
30
  "title": "Evo Government Copilot (Mauritius)",
@@ -36,6 +25,8 @@ _STRINGS: Dict[str, Dict[str, str]] = {
36
  "intro_ok": "Answer (grounded in retrieved sources):",
37
  "intro_err": "I couldn’t find enough information. Try rephrasing or add official documents.",
38
  "sources": "Sources",
 
 
39
  "tip_build": "Tip: Click 'Build/Refresh Index' first.",
40
  },
41
  "fr": {
@@ -48,6 +39,8 @@ _STRINGS: Dict[str, Dict[str, str]] = {
48
  "intro_ok": "Réponse (fondée sur les sources récupérées) :",
49
  "intro_err": "Je n’ai pas trouvé assez d’informations. Reformulez ou ajoutez des documents officiels.",
50
  "sources": "Sources",
 
 
51
  "tip_build": "Astuce : cliquez d’abord sur « Construire/Actualiser l’index ».",
52
  },
53
  "mfe": {
@@ -60,14 +53,13 @@ _STRINGS: Dict[str, Dict[str, str]] = {
60
  "intro_ok": "Repons (lor sours ki finn gagne):",
61
  "intro_err": "Pena ase informasion. Esay rephrase ouswa azout dokiman ofisiel.",
62
  "sources": "Sours",
 
 
63
  "tip_build": "Tip: Klik « Bati/Rafresir Index » avan.",
64
  },
65
  }
66
 
67
  def L(lang: str, key: str) -> str:
68
- """
69
- (Objective) Return localized string; fallback to English if missing.
70
- """
71
  lang = normalize_lang(lang)
72
  if key in _STRINGS.get(lang, {}):
73
  return _STRINGS[lang][key]
 
1
  """
2
  utils_lang.py
3
+ Step 5/6: Language helpers for EN / FR / Kreol Morisien (MFE).
 
 
 
 
 
 
 
4
  """
5
 
6
  from typing import Dict
7
 
 
8
  SUPPORTED = {
9
  "en": "English",
10
  "fr": "Français",
 
12
  }
13
 
14
  def normalize_lang(code: str) -> str:
 
15
  return code if code in SUPPORTED else "en"
16
 
 
 
17
  _STRINGS: Dict[str, Dict[str, str]] = {
18
  "en": {
19
  "title": "Evo Government Copilot (Mauritius)",
 
25
  "intro_ok": "Answer (grounded in retrieved sources):",
26
  "intro_err": "I couldn’t find enough information. Try rephrasing or add official documents.",
27
  "sources": "Sources",
28
+ "links": "Official links",
29
+ "forms": "Forms",
30
  "tip_build": "Tip: Click 'Build/Refresh Index' first.",
31
  },
32
  "fr": {
 
39
  "intro_ok": "Réponse (fondée sur les sources récupérées) :",
40
  "intro_err": "Je n’ai pas trouvé assez d’informations. Reformulez ou ajoutez des documents officiels.",
41
  "sources": "Sources",
42
+ "links": "Liens officiels",
43
+ "forms": "Formulaires",
44
  "tip_build": "Astuce : cliquez d’abord sur « Construire/Actualiser l’index ».",
45
  },
46
  "mfe": {
 
53
  "intro_ok": "Repons (lor sours ki finn gagne):",
54
  "intro_err": "Pena ase informasion. Esay rephrase ouswa azout dokiman ofisiel.",
55
  "sources": "Sours",
56
+ "links": "Lyen ofisiel",
57
+ "forms": "Formiler",
58
  "tip_build": "Tip: Klik « Bati/Rafresir Index » avan.",
59
  },
60
  }
61
 
62
  def L(lang: str, key: str) -> str:
 
 
 
63
  lang = normalize_lang(lang)
64
  if key in _STRINGS.get(lang, {}):
65
  return _STRINGS[lang][key]