#!/usr/bin/env bash # i18n.sh — language for taler-monitoring console + HTML chrome # # TALER_MON_LANG=en|fr # TALER_MON_LANG_SET=1 → language is explicit (--lang only); do not override. # Auto (SET≠1), in order: # 1) TALER_DOMAIN_LANG from domains.conf profile (preferred — source of truth) # 2) fallback hostname heuristic *lefrancpaysan*/*francpaysan* → fr # 3) else keep workstation env TALER_MON_LANG or en # # domains.conf column `lang` (see suite domains.conf) is the global definition. # Bare TALER_MON_LANG=en in ~/.config must not override a profile lang=fr. : "${TALER_MON_LANG:=}" : "${TALER_MON_LANG_SET:=0}" : "${TALER_DOMAIN_LANG:=}" i18n_init() { # Only TALER_MON_LANG_SET=1 is "explicit". Do not promote non-empty TALER_MON_LANG # to SET=1 — env files often ship LANG=en for the default GOA workstation. if [ "${TALER_MON_LANG_SET:-0}" != "1" ]; then if [ -n "${TALER_DOMAIN_LANG:-}" ]; then TALER_MON_LANG="$TALER_DOMAIN_LANG" else case "${TALER_DOMAIN:-}" in *lefrancpaysan*|*francpaysan*) # fallback if domain not (yet) in domains.conf TALER_MON_LANG=fr ;; *) if [ -z "${TALER_MON_LANG:-}" ]; then TALER_MON_LANG=en fi ;; esac fi fi case "${TALER_MON_LANG}" in fr|FR|fra|french) TALER_MON_LANG=fr ;; *) TALER_MON_LANG=en ;; esac export TALER_MON_LANG export TALER_MON_LANG_SET export TALER_DOMAIN_LANG } i18n_tag() { local t="$1" if [ "${TALER_MON_LANG:-en}" != "fr" ]; then printf '%s' "$t" return 0 fi case "$t" in OK) printf 'OK' ;; ERROR) printf 'ERREUR' ;; WARN) printf 'AVERT' ;; INFO) printf 'INFO' ;; BLOCKER) printf 'BLOCAGE' ;; BLOCK) printf 'BLOC' ;; SUMMARY) printf 'RESUME' ;; PROG|PROGRESS) printf 'PROG' ;; *) printf '%s' "$t" ;; esac } i18n_text() { local s="$*" if [ "${TALER_MON_LANG:-en}" != "fr" ] || [ -z "$s" ]; then printf '%s' "$s" return 0 fi case "$s" in "numbered checks this run:") printf 'controles numerotes de cette execution :' ;; "numbered checks:") printf 'controles numerotes :' ;; "(global done/total)") printf '(fait/total global)' ;; "global checks:") printf 'controles globaux :' ;; "failed — see list above"|"failed - see list above") printf 'echec — voir la liste ci-dessus' ;; "BLOCKERS · pay/withdraw cannot finish") printf 'BLOCAGES · paiement/retrait impossible' ;; "BLOCKERS (pay/withdraw cannot finish)") printf 'BLOCAGES (paiement/retrait impossible)' ;; "ERRORS · failed checks") printf 'ERREURS · controles en echec' ;; "ERRORS (failed checks)") printf 'ERREURS (controles en echec)' ;; "pay/withdraw cannot finish") printf 'paiement/retrait impossible a terminer' ;; "SUMMARY") printf 'RESUME' ;; "totals:") printf 'totaux :' ;; "all clear") printf 'tout est clair' ;; "warnings only (no hard fail)") printf 'avertissements seulement (pas d'\''echec dur)' ;; "monitoring") printf 'surveillance' ;; "surface") printf 'surface' ;; "aptdeploy") printf 'aptdeploy' ;; "container") printf 'conteneur' ;; "disk") printf 'disque' ;; "package") printf 'paquet' ;; "version") printf 'version' ;; "reachability") printf 'accessibilite' ;; "server-header") printf 'en-tete Server' ;; "inventory") printf 'inventaire' ;; "flags") printf 'options' ;; "target domain") printf 'domaine cible' ;; "currency") printf 'devise' ;; "phases") printf 'phases' ;; "access") printf 'acces' ;; *) local out="$s" out=${out//shared library missing/bibliotheque partagee manquante} out=${out//shared library error/erreur de bibliotheque partagee} out=${out//not active/non actif} out=${out//after_start/apres_demarrage} out=${out//catalogued but not reachable/catalogue mais inaccessible} out=${out//does not resolve/ne resout pas} out=${out//protocol confirmed/protocole confirme} out=${out//catalogued service OK/service catalogue OK} out=${out//from Server header/depuis en-tete Server} out=${out//OSV clean/OSV sans vulnerabilite} out=${out//actionable vuln/vuln. actionnable} out=${out//header version · not Debian pkg/version en-tete · pas paquet Debian} out=${out//RUN_TIMEOUT exceeded/RUN_TIMEOUT depasse} out=${out//public HTTPS/HTTPS public} out=${out//container status/etat du conteneur} out=${out//remote-only/uniquement distant} out=${out//no SSH/sans SSH} out=${out//failed — see list above/echec — voir la liste ci-dessus} printf '%s' "$out" ;; esac }