rewrite locales

This commit is contained in:
Marc Beninca 2024-09-04 15:22:03 +02:00
parent dc51f1eba6
commit 1773608215
Signed by: marc.beninca
GPG key ID: 9C7613450C80C24F

View file

@ -919,46 +919,64 @@ spcd_txt_locale() {
esac esac
} }
spcd_txt_locales_echo() {
spcd_os_printenv "LANGUAGE"
locale --all-locales
}
spcd_txt_locales() { spcd_txt_locales() {
local action="${1}"
local chosen="${2}"
set -- \ set -- \
"${SPCD_TXT_LOCALE_ENGLISH}" \ "${SPCD_TXT_LOCALE_ENGLISH}" \
"${SPCD_TXT_LOCALE_FRENCH}" "${SPCD_TXT_LOCALE_FRENCH}"
local language locale text local name
spcd_txt_locales_echo case "${action}" in
spcd_split "install")
for locale in "${@}"; do spcd_txt_locales "list"
case "${1}" in spcd_split
"glibc-langpack-") case "${SPCD_PM}" in
language="$(echo "${locale}" | cut -d _ -f 1)" "${SPCD_PM_APK}") spcd_install_package "musl-locales" ;;
spcd_install_package "glibc-langpack-${language}" "${SPCD_PM_APT}")
;; local text
"LANGUAGE") for name in "${@}"; do
if [ -n "${text}" ]; then text="${text}\
text="${text}:${locale}" ${name}.${_SPCD_TXT_CHARSET} ${_SPCD_TXT_CHARSET}
else
text="${locale}"
fi
;;
"locale.gen")
text="${text}\
${locale}.${_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 esac
done spcd_split
case "${1}" in spcd_txt_locales "list"
"LANGUAGE") export LANGUAGE="${text}" ;; ;;
"locale.gen") spcd_os_write "/etc/locale.gen" "${text}" ;; "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 esac
spcd_split
spcd_txt_locales_echo
} }
# ╭──────┬─────╮ # ╭──────┬─────╮