From 17736082156338a92912b72b2ff91396d364e1d4 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Wed, 4 Sep 2024 15:22:03 +0200 Subject: [PATCH] rewrite locales --- spcd/bootstrap.sh | 78 +++++++++++++++++++++++++++++------------------ 1 file changed, 48 insertions(+), 30 deletions(-) diff --git a/spcd/bootstrap.sh b/spcd/bootstrap.sh index be162b6..75a09f1 100644 --- a/spcd/bootstrap.sh +++ b/spcd/bootstrap.sh @@ -919,46 +919,64 @@ spcd_txt_locale() { esac } -spcd_txt_locales_echo() { - spcd_os_printenv "LANGUAGE" - locale --all-locales -} - spcd_txt_locales() { + local action="${1}" + local chosen="${2}" set -- \ "${SPCD_TXT_LOCALE_ENGLISH}" \ "${SPCD_TXT_LOCALE_FRENCH}" - local language locale text - spcd_txt_locales_echo - spcd_split - for locale in "${@}"; do - case "${1}" in - "glibc-langpack-") - language="$(echo "${locale}" | cut -d _ -f 1)" - spcd_install_package "glibc-langpack-${language}" - ;; - "LANGUAGE") - if [ -n "${text}" ]; then - text="${text}:${locale}" - else - text="${locale}" - fi - ;; - "locale.gen") - text="${text}\ -${locale}.${_SPCD_TXT_CHARSET} ${_SPCD_TXT_CHARSET} + local name + case "${action}" in + "install") + spcd_txt_locales "list" + spcd_split + case "${SPCD_PM}" in + "${SPCD_PM_APK}") spcd_install_package "musl-locales" ;; + "${SPCD_PM_APT}") + local text + for name in "${@}"; do + text="${text}\ +${name}.${_SPCD_TXT_CHARSET} ${_SPCD_TXT_CHARSET} " + done + spcd_os_write "/etc/locale.gen" "${text}" ;; + "${SPCD_PM_DNF}") + local language + for name in "${@}"; do + language="$(echo "${name}" | cut -d _ -f 1)" + spcd_install_package "glibc-langpack-${language}" + done + ;; + "${SPCD_PM_PACMAN}") spcd_install_package "glibc-locales" ;; + "${SPCD_PM_ZYPPER}") spcd_install_package "glibc-locale" ;; *) ;; esac - done - case "${1}" in - "LANGUAGE") export LANGUAGE="${text}" ;; - "locale.gen") spcd_os_write "/etc/locale.gen" "${text}" ;; + spcd_split + spcd_txt_locales "list" + ;; + "language") + local text + if [ -n "${chosen}" ]; then + text="${chosen}" + fi + for name in "${@}"; do + if [ "${name}" != "${chosen}" ]; then + if [ -n "${text}" ]; then + text="${text}:${name}" + else + text="${name}" + fi + fi + done + ;; + "list") + if ! locale --all-locales; then + echo "No locales yet!" + fi + ;; *) ;; esac - spcd_split - spcd_txt_locales_echo } # ╭──────┬─────╮