i18n: English default, French for FrancPaysan (v1.1)
This commit is contained in:
parent
a2afe690b7
commit
334594c423
13 changed files with 483 additions and 86 deletions
61
lib.sh
61
lib.sh
|
|
@ -2,6 +2,18 @@
|
|||
# Shared helpers for taler-monitoring (laptop or koopa).
|
||||
|
||||
# Default stack = GOA / hacktivism (overridden by TALER_DOMAIN / --domain)
|
||||
# i18n (en default; fr for FrancPaysan — see i18n.sh / TALER_MON_LANG)
|
||||
_I18N_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||
if [ -f "$_I18N_DIR/i18n.sh" ]; then
|
||||
# shellcheck source=i18n.sh
|
||||
source "$_I18N_DIR/i18n.sh"
|
||||
i18n_init
|
||||
else
|
||||
i18n_tag() { printf '%s' "$1"; }
|
||||
i18n_text() { printf '%s' "$*"; }
|
||||
i18n_init() { :; }
|
||||
fi
|
||||
|
||||
: "${TALER_DOMAIN:=hacktivism.ch}"
|
||||
: "${BANK_PUBLIC:=https://bank.hacktivism.ch}"
|
||||
: "${EXCHANGE_PUBLIC:=https://exchange.hacktivism.ch}"
|
||||
|
|
@ -114,6 +126,11 @@ set_taler_stack() {
|
|||
BANK_PUBLIC=${BANK_PUBLIC%/}
|
||||
EXCHANGE_PUBLIC=${EXCHANGE_PUBLIC%/}
|
||||
MERCHANT_PUBLIC=${MERCHANT_PUBLIC%/}
|
||||
# re-evaluate language after domain profile (FrancPaysan → fr)
|
||||
if [ "${TALER_MON_LANG_SET:-0}" != "1" ]; then
|
||||
TALER_MON_LANG=
|
||||
i18n_init
|
||||
fi
|
||||
}
|
||||
|
||||
# Load first matching profile from domains.conf.
|
||||
|
|
@ -265,6 +282,11 @@ apply_taler_domain() {
|
|||
BANK_PUBLIC=${BANK_PUBLIC%/}
|
||||
EXCHANGE_PUBLIC=${EXCHANGE_PUBLIC%/}
|
||||
MERCHANT_PUBLIC=${MERCHANT_PUBLIC%/}
|
||||
# re-evaluate language after domain profile (FrancPaysan → fr)
|
||||
if [ "${TALER_MON_LANG_SET:-0}" != "1" ]; then
|
||||
TALER_MON_LANG=
|
||||
i18n_init
|
||||
fi
|
||||
|
||||
# Koopa SSH only for LOCAL_STACK=1. Stage LFP uses INSIDE_SSH (stagepaysan) separately.
|
||||
if [ "${LOCAL_STACK}" != "1" ]; then
|
||||
|
|
@ -679,6 +701,10 @@ _fmt_badge() {
|
|||
# $1=badge style $2=tag text $3=label colour $4=label $5=detail
|
||||
_msg_line() {
|
||||
local badge="$1" tag="$2" lcol="$3" label="$4" detail="${5:-}"
|
||||
# i18n: tags + free text (en default; fr for FrancPaysan)
|
||||
tag=$(i18n_tag "$tag")
|
||||
label=$(i18n_text "$label")
|
||||
[ -n "$detail" ] && detail=$(i18n_text "$detail")
|
||||
if [ -n "$detail" ]; then
|
||||
printf -- '%s %s%s%s%s %s·%s %s%s%s\n' \
|
||||
"$(_fmt_badge "$badge" "$tag")" "$(_fmt_tid)" "$lcol" "$label" "$N" "$D" "$N" "$D" "$detail" "$N"
|
||||
|
|
@ -749,7 +775,8 @@ blocker() {
|
|||
}
|
||||
section() {
|
||||
# Boxed section header (3 lines when colour on)
|
||||
local title="$*"
|
||||
local title
|
||||
title=$(i18n_text "$*")
|
||||
local w=${#title}
|
||||
[ "$w" -lt 24 ] && w=24
|
||||
[ "$w" -gt 56 ] && w=56
|
||||
|
|
@ -783,13 +810,13 @@ summary() {
|
|||
_progress_bar_line "$PROGRESS_DONE" "$PROGRESS_TOTAL"
|
||||
fi
|
||||
if [ "$GLOBAL_N" -gt 0 ]; then
|
||||
printf -- '%s numbered checks this run: #001…#%03d%s\n' "$D" "$GLOBAL_N" "$N"
|
||||
printf -- '%s %s #001…#%03d%s\n' "$D" "$(i18n_text 'numbered checks this run:')" "$GLOBAL_N" "$N"
|
||||
fi
|
||||
if [ "$blk_n" -gt 0 ]; then
|
||||
if [ "${BOX:-0}" = "1" ]; then
|
||||
printf -- '%s┌ BLOCKERS · pay/withdraw cannot finish ┐%s\n' "$BG_BLK" "$N"
|
||||
printf -- '%s┌ %s ┐%s\n' "$BG_BLK" "$(i18n_text 'BLOCKERS · pay/withdraw cannot finish')" "$N"
|
||||
else
|
||||
printf -- '%s--- BLOCKERS (pay/withdraw cannot finish) ---%s\n' "$M" "$N"
|
||||
printf -- '%s--- %s ---%s\n' "$M" "$(i18n_text 'BLOCKERS (pay/withdraw cannot finish)')" "$N"
|
||||
fi
|
||||
local b
|
||||
for b in "${BLOCKERS[@]}"; do
|
||||
|
|
@ -798,9 +825,9 @@ summary() {
|
|||
fi
|
||||
if [ "${#ERRORS[@]}" -gt 0 ] && [ "$blk_n" -lt "${#ERRORS[@]}" ]; then
|
||||
if [ "${BOX:-0}" = "1" ]; then
|
||||
printf -- '%s┌ ERRORS · failed checks ┐%s\n' "$BG_ERR" "$N"
|
||||
printf -- '%s┌ %s ┐%s\n' "$BG_ERR" "$(i18n_text 'ERRORS · failed checks')" "$N"
|
||||
else
|
||||
printf -- '%s--- ERRORS (failed checks) ---%s\n' "$R" "$N"
|
||||
printf -- '%s--- %s ---%s\n' "$R" "$(i18n_text 'ERRORS (failed checks)')" "$N"
|
||||
fi
|
||||
local e
|
||||
for e in "${ERRORS[@]}"; do
|
||||
|
|
@ -811,9 +838,11 @@ summary() {
|
|||
|
||||
# Coloured totals — same severity badges as check lines (always; NO_COLOR blanks ANSI)
|
||||
if [ "${BOX:-0}" = "1" ]; then
|
||||
printf -- '\n%s┌ SUMMARY ┐%s\n' "$BG_SEC" "$N"
|
||||
printf -- '\n%s┌ %s ┐%s\n' "$BG_SEC" "$(i18n_tag SUMMARY)" "$N"
|
||||
_sum_badge() { # $1=bg $2=tag $3=fg $4=n
|
||||
printf -- ' %s┌ %-5s┐%s %s%4d%s\n' "$1" "$2" "$N" "$3" "$4" "$N"
|
||||
local _tg
|
||||
_tg=$(i18n_tag "$2")
|
||||
printf -- ' %s┌ %-5s┐%s %s%4d%s\n' "$1" "$_tg" "$N" "$3" "$4" "$N"
|
||||
}
|
||||
_sum_badge "$BG_OK" "OK" "$G" "$PASS_N"
|
||||
[ "$FAIL_N" -gt 0 ] && _sum_badge "$BG_ERR" "ERROR" "$R" "$FAIL_N"
|
||||
|
|
@ -821,12 +850,12 @@ summary() {
|
|||
[ "$INFO_N" -gt 0 ] && _sum_badge "$BG_INFO" "INFO" "$C" "$INFO_N"
|
||||
[ "$blk_n" -gt 0 ] && _sum_badge "$BG_BLK" "BLOCK" "$M" "$blk_n"
|
||||
else
|
||||
printf -- '\n[ SUMMARY ]\n'
|
||||
printf -- ' [ OK ] %s%4d%s\n' "$G" "$PASS_N" "$N"
|
||||
[ "$FAIL_N" -gt 0 ] && printf -- ' [ ERROR ] %s%4d%s\n' "$R" "$FAIL_N" "$N"
|
||||
[ "$WARN_N" -gt 0 ] && printf -- ' [ WARN ] %s%4d%s\n' "$Y" "$WARN_N" "$N"
|
||||
[ "$INFO_N" -gt 0 ] && printf -- ' [ INFO ] %s%4d%s\n' "$C" "$INFO_N" "$N"
|
||||
[ "$blk_n" -gt 0 ] && printf -- ' [ BLOCK ] %s%4d%s\n' "$M" "$blk_n" "$N"
|
||||
printf -- '\n[ %s ]\n' "$(i18n_tag SUMMARY)"
|
||||
printf -- ' [ %-5s ] %s%4d%s\n' "$(i18n_tag OK)" "$G" "$PASS_N" "$N"
|
||||
[ "$FAIL_N" -gt 0 ] && printf -- ' [ %-5s ] %s%4d%s\n' "$(i18n_tag ERROR)" "$R" "$FAIL_N" "$N"
|
||||
[ "$WARN_N" -gt 0 ] && printf -- ' [ %-5s ] %s%4d%s\n' "$(i18n_tag WARN)" "$Y" "$WARN_N" "$N"
|
||||
[ "$INFO_N" -gt 0 ] && printf -- ' [ %-5s ] %s%4d%s\n' "$(i18n_tag INFO)" "$C" "$INFO_N" "$N"
|
||||
[ "$blk_n" -gt 0 ] && printf -- ' [ %-5s ] %s%4d%s\n' "$(i18n_tag BLOCK)" "$M" "$blk_n" "$N"
|
||||
fi
|
||||
# one-line rollup (bold label, severity-coloured counts)
|
||||
printf -- ' %stotals:%s %s%d OK%s' "$B" "$N" "$G" "$PASS_N" "$N"
|
||||
|
|
@ -850,9 +879,9 @@ summary() {
|
|||
fi
|
||||
else
|
||||
if [ "${BOX:-0}" = "1" ]; then
|
||||
printf -- ' %s┌ ERROR ┐%s %sfailed — see list above%s\n' "$BG_ERR" "$N" "$R" "$N"
|
||||
printf -- ' %s┌ ERROR ┐%s %s"$(i18n_text "failed — see list above")"%s\n' "$BG_ERR" "$N" "$R" "$N"
|
||||
else
|
||||
printf -- ' %s[ ERROR ] failed — see list above%s\n' "$R" "$N"
|
||||
printf -- ' %s[ ERROR ] "$(i18n_text "failed — see list above")"%s\n' "$R" "$N"
|
||||
fi
|
||||
fi
|
||||
[ "$FAIL_N" -eq 0 ]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue