release 1.20.0: domains.conf locale l10n + optional German UI

Add locale column (fr-CH for FP, de-CH elsewhere; ch-FR/ch-DE aliases).
Introduce UI lang=de (tags + sticky) without using de as any stock default.
This commit is contained in:
Hernâni Marques 2026-07-19 11:13:47 +02:00
parent 915e361157
commit c435df9728
No known key found for this signature in database
GPG key ID: CB5738652768F7E9
8 changed files with 408 additions and 163 deletions

70
lib.sh
View file

@ -166,24 +166,53 @@ set_taler_stack() {
fi
}
# Normalize domains.conf lang token → en|fr (empty if not a lang token).
# Normalize domains.conf UI lang token → en|fr|de (empty if not a lang token).
# Note: de is valid for --lang / explicit profile, but no stock profile defaults to de.
_domain_lang_token() {
case "${1:-}" in
en|EN|eng|english) printf 'en' ;;
fr|FR|fra|french) printf 'fr' ;;
de|DE|deu|ger|german|deutsch) printf 'de' ;;
*) printf '' ;;
esac
}
# Normalize regional locale → BCP 47 (fr-CH, de-CH, en-CH, …). Empty if unknown.
# Accepts fr-CH, fr_CH, ch-FR / de-CH, ch-DE (user-friendly aliases).
_domain_locale_token() {
local t="${1:-}"
t=$(printf '%s' "$t" | tr '[:upper:]' '[:lower:]' | tr '_' '-')
case "$t" in
fr-ch|ch-fr|fr_ch) printf 'fr-CH' ;;
de-ch|ch-de|de_ch) printf 'de-CH' ;;
en-ch|ch-en|en_ch) printf 'en-CH' ;;
en-us|en-gb|fr-fr|de-de|it-ch|rm-ch)
# pass through other xx-YY
printf '%s' "$t" | awk -F- '{printf "%s-%s", tolower($1), toupper($2)}'
;;
*)
# bare xx-YY pattern
if printf '%s' "$t" | grep -qE '^[a-z]{2}-[a-z]{2}$'; then
printf '%s' "$t" | awk -F- '{printf "%s-%s", tolower($1), toupper($2)}'
else
printf ''
fi
;;
esac
}
# Load first matching profile from domains.conf.
# Fields (whitespace-separated; # comments; blank lines ignored):
# name bank exchange merchant currency local[0|1] landing[0|1] lang[en|fr] [canonical]
# Legacy: 8th field may be canonical only (no lang) — lang defaults to en.
# Sets TALER_DOMAIN_LANG from the profile (i18n source of truth when SET≠1).
# name bank exchange merchant currency local landing lang locale [canonical]
# Legacy:
# … landing lang [canonical] → locale defaulted
# … landing [canonical] → lang=en, locale defaulted
# Sets TALER_DOMAIN_LANG + TALER_DOMAIN_LOCALE from the profile.
# Returns 0 if found, 1 if not.
load_domain_profile() {
local want="$1" conf="${TALER_DOMAINS_CONF:-}"
local line name bank exchange merchant currency local_stack landing canon profile_lang f8 f9
local line name bank exchange merchant currency local_stack landing canon
local profile_lang profile_locale f8 f9 f10
[ -n "$want" ] || return 1
[ -n "$conf" ] && [ -f "$conf" ] || return 1
@ -202,28 +231,53 @@ load_domain_profile() {
landing="${7:-}"
f8="${8:-}"
f9="${9:-}"
f10="${10:-}"
canon="$name"
profile_lang=""
profile_locale=""
# Backward compat: old 7th field was canonical domain (contains a dot)
if [ -n "$landing" ] && [[ "$landing" == *.* && "$landing" != "0" && "$landing" != "1" ]]; then
canon="$landing"
landing=""
f8="${7:-}"
f9="${8:-}"
f10="${9:-}"
fi
if [ -n "$f8" ]; then
profile_lang=$(_domain_lang_token "$f8")
if [ -n "$profile_lang" ]; then
canon="${f9:-$name}"
# modern: lang [locale] [canonical]
profile_locale=$(_domain_locale_token "$f9")
if [ -n "$profile_locale" ]; then
canon="${f10:-$name}"
else
# lang + canonical (no locale column)
if [ -n "$f9" ] && [ -z "$(_domain_lang_token "$f9")" ]; then
canon="$f9"
else
canon="${f9:-$name}"
fi
profile_locale=$(_domain_locale_token "$f10")
fi
else
# legacy: field 8 = canonical, optional field 9 = lang
# legacy: field 8 = canonical only
canon="$f8"
profile_lang=$(_domain_lang_token "$f9")
profile_locale=$(_domain_locale_token "${f10:-$f9}")
[ -z "$profile_lang" ] && profile_lang=en
fi
fi
[ -z "$profile_lang" ] && profile_lang=en
if [ -z "$profile_locale" ]; then
# default regional locale: FP → fr-CH, else de-CH
case "$name$canon$bank$merchant" in
*lefrancpaysan*|*francpaysan*) profile_locale=fr-CH ;;
*) profile_locale=de-CH ;;
esac
fi
TALER_DOMAIN_LANG="$profile_lang"
export TALER_DOMAIN_LANG
TALER_DOMAIN_LOCALE="$profile_locale"
export TALER_DOMAIN_LANG TALER_DOMAIN_LOCALE
set_taler_stack "$bank" "$exchange" "$merchant" "$currency" "$local_stack" "$landing" "$canon"
return 0
done <"$conf"