From 532414813610098d653d26f9c44ec5cd551c371e Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 1 Sep 2024 19:01:54 +0200 Subject: [PATCH] spcd_txt_locales --- spcd/bootstrap.sh | 56 +++++++++++++++++++++++++++++++++-------------- 1 file changed, 40 insertions(+), 16 deletions(-) diff --git a/spcd/bootstrap.sh b/spcd/bootstrap.sh index 7aba2c8..1d0592e 100644 --- a/spcd/bootstrap.sh +++ b/spcd/bootstrap.sh @@ -343,7 +343,6 @@ spcd_txt_get() { } spcd_txt_locale() { - # LANGUAGE local value name if [ -n "${1}" ]; then value="${1}" @@ -370,6 +369,43 @@ spcd_txt_locale() { done } +spcd_txt_locales() { + set -- \ + "${SPCD_TXT_LOCALE_ENGLISH}" \ + "${SPCD_TXT_LOCALE_FRENCH}" + local locale + case "${1}" in + "glibc-langpack-") + local language + for locale in "${@}"; do + language="$(echo "${locale}" | cut -d _ -f 1)" + spcd_install_package "glibc-langpack-${language}" + done + ;; + "LANGUAGE") + local text + for locale in "${@}"; do + if [ -n "${text}" ]; then + text="${text}:${locale}" + else + text="${locale}" + fi + done + export LANGUAGE="${text}" + ;; + "locale.gen") + local text + for locale in "${@}"; do + text="${text}\ +${locale}.${_SPCD_TXT_CHARSET} ${_SPCD_TXT_CHARSET} +" + done + spcd_os_write "/etc/locale.gen" "${text}" + ;; + *) ;; + esac +} + # ╭──────╮ # │ step │ # ╰──────╯ @@ -1178,32 +1214,20 @@ spcd_step__packages_verify_https() { spcd_step__packages_install_locales() { spcd_step "Install locales" - set -- \ - "${SPCD_TXT_LOCALE_ENGLISH}" \ - "${SPCD_TXT_LOCALE_FRENCH}" case "${SPCD_PM}" in "${SPCD_PM_APK}") spcd_install_package "musl-locales" ;; "${SPCD_PM_APT}") - local locale text - for locale in "${@}"; do - text="${text}\ -${locale}.${_SPCD_TXT_CHARSET} ${_SPCD_TXT_CHARSET} -" - done - spcd_os_write "/etc/locale.gen" "${text}" + spcd_txt_locales "locale.gen" spcd_install_package "locales" ;; "${SPCD_PM_DNF}") - local locale language - for locale in "${@}"; do - language="$(echo "${locale}" | cut -d _ -f 1)" - spcd_install_package "glibc-langpack-${language}" - done + spcd_txt_locales "glibc-langpack-" ;; "${SPCD_PM_PACMAN}") spcd_install_package "glibc-locales" ;; "${SPCD_PM_ZYPPER}") spcd_install_package "glibc-locale" ;; *) ;; esac + spcd_txt_locales "LANGUAGE" spcd_txt_locale "${SPCD_TXT_LOCALE}" }