release 1.18.9: FP domains default UI language fr globally
Workstation TALER_MON_LANG=en no longer locks English on *lefrancpaysan*; only --lang / TALER_MON_LANG_SET=1 overrides. host-agent + HTML chrome.
This commit is contained in:
parent
56709c4700
commit
d664ad0a6e
5 changed files with 57 additions and 42 deletions
|
|
@ -45,15 +45,35 @@ def atomic_write_text(path: Path, text: str, encoding: str = "utf-8") -> None:
|
|||
except OSError:
|
||||
pass
|
||||
|
||||
def ui_lang(explicit: str = "") -> str:
|
||||
"""en (default) or fr. Env: TALER_MON_LANG; auto fr for lefrancpaysan hosts."""
|
||||
def ui_lang(explicit: str = "", host_hint: str = "") -> str:
|
||||
"""en (default) or fr.
|
||||
|
||||
- TALER_MON_LANG_SET=1 → honour TALER_MON_LANG / explicit only (no host auto).
|
||||
- Else: any *lefrancpaysan* / *francpaysan* host or log hint → fr
|
||||
(workstation env TALER_MON_LANG=en must not force English on FP domains).
|
||||
- Else: explicit / env / en.
|
||||
"""
|
||||
import os
|
||||
lang = (explicit or os.environ.get("TALER_MON_LANG") or "").strip().lower()
|
||||
if lang in ("fr", "fra", "french"):
|
||||
|
||||
env_lang = (os.environ.get("TALER_MON_LANG") or "").strip().lower()
|
||||
lang = (explicit or env_lang or "").strip().lower()
|
||||
locked = (os.environ.get("TALER_MON_LANG_SET") or "").strip() == "1"
|
||||
is_fp = bool(
|
||||
re.search(r"lefrancpaysan|francpaysan", host_hint or "", re.I)
|
||||
)
|
||||
|
||||
def _norm(v: str) -> str:
|
||||
if v in ("fr", "fra", "french"):
|
||||
return "fr"
|
||||
if v in ("en", "eng", "english"):
|
||||
return "en"
|
||||
return ""
|
||||
|
||||
if locked:
|
||||
return _norm(lang) or "en"
|
||||
if is_fp:
|
||||
return "fr"
|
||||
if lang in ("en", "eng", "english"):
|
||||
return "en"
|
||||
return "en"
|
||||
return _norm(lang) or "en"
|
||||
|
||||
|
||||
def ui(lang: str, key: str, **kwargs) -> str:
|
||||
|
|
@ -709,11 +729,9 @@ def monitoring_scope(
|
|||
label = (page_label or "monitoring").lower().replace("_", "-")
|
||||
phases = extract_phases(log_text)
|
||||
host = hostname or "?"
|
||||
# Auto-fr for FrancPaysan hosts if lang not forced
|
||||
if lang == "en" and re.search(r"lefrancpaysan|francpaysan", host + " " + log_text, re.I):
|
||||
import os
|
||||
if not (os.environ.get("TALER_MON_LANG") or "").strip():
|
||||
lang = "fr"
|
||||
# Resolve lang again with host/log hint (*lefrancpaysan* → fr unless LANG_SET=1)
|
||||
_ex = lang if lang in ("en", "fr") else ""
|
||||
lang = ui_lang(explicit=_ex, host_hint=host + " " + log_text)
|
||||
|
||||
if "surface" in label:
|
||||
items = [
|
||||
|
|
@ -1079,10 +1097,7 @@ def sticky_bar_html(
|
|||
if scope and scope.get("lang"):
|
||||
lang = str(scope.get("lang"))
|
||||
else:
|
||||
lang = ui_lang()
|
||||
# auto-fr for FP hostnames
|
||||
if lang == "en" and re.search(r"lefrancpaysan|francpaysan", hostname or "", re.I):
|
||||
lang = "fr"
|
||||
lang = ui_lang(host_hint=hostname or "")
|
||||
|
||||
if level == "red":
|
||||
status_txt = ui(lang, "errors")
|
||||
|
|
@ -1990,12 +2005,7 @@ def build_html(
|
|||
page_label or ""
|
||||
).lower()
|
||||
if _is_apt:
|
||||
_lang_board = ui_lang()
|
||||
if re.search(r"lefrancpaysan|francpaysan", hostname + "\n" + log_text, re.I):
|
||||
import os
|
||||
|
||||
if not (os.environ.get("TALER_MON_LANG") or "").strip():
|
||||
_lang_board = "fr"
|
||||
_lang_board = ui_lang(host_hint=hostname + "\n" + log_text)
|
||||
err_nav += aptdeploy_board_html(log_text, lang=_lang_board)
|
||||
|
||||
if errors and mode == "err":
|
||||
|
|
@ -2040,11 +2050,7 @@ def build_html(
|
|||
|
||||
first_err_href = "#first-error" if first_err_i is not None else None
|
||||
first_warn_href = "#first-warn" if first_warn_i is not None else None
|
||||
lang = ui_lang()
|
||||
if re.search(r"lefrancpaysan|francpaysan", hostname + "\n" + log_text, re.I):
|
||||
import os
|
||||
if not (os.environ.get("TALER_MON_LANG") or "").strip():
|
||||
lang = "fr"
|
||||
lang = ui_lang(host_hint=hostname + "\n" + log_text)
|
||||
scope = monitoring_scope(page_label, hostname, log_text, lang=lang)
|
||||
|
||||
page_lang = lang
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue