# i18n loader. Exposes the MSG associative array and the `t` accessor. # # i18n_load en # populate MSG from i18n/en.sh # t step_db # echo MSG[step_db] # t pull_images foo # printf MSG[pull_images] with args (for %s placeholders) # # Strings live in i18n/.sh; logic never hardcodes user-facing text. declare -A MSG i18n_load() { local locale="$1" local file="${BOOTSTRAP_DIR}/i18n/${locale}.sh" [[ -f "$file" ]] || file="${BOOTSTRAP_DIR}/i18n/en.sh" # shellcheck source=/dev/null source "$file" LOCALE="$locale" } # t KEY [printf-args...] — resolve a string, optionally formatting placeholders. t() { local key="$1"; shift local s="${MSG[$key]:-$key}" if (($# > 0)); then # shellcheck disable=SC2059 printf "$s" "$@" else printf '%s' "$s" fi }