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
}
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
local name
case "${action}" in
"install")
spcd_txt_locales "list"
spcd_split
for locale in "${@}"; do
case "${1}" in
"glibc-langpack-")
language="$(echo "${locale}" | cut -d _ -f 1)"
spcd_install_package "glibc-langpack-${language}"
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}"
;;
"LANGUAGE")
"${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
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}:${locale}"
text="${text}:${name}"
else
text="${locale}"
text="${name}"
fi
fi
done
;;
"list")
if ! locale --all-locales; then
echo "No locales yet!"
fi
;;
"locale.gen")
text="${text}\
${locale}.${_SPCD_TXT_CHARSET} ${_SPCD_TXT_CHARSET}
"
;;
*) ;;
esac
done
case "${1}" in
"LANGUAGE") export LANGUAGE="${text}" ;;
"locale.gen") spcd_os_write "/etc/locale.gen" "${text}" ;;
*) ;;
esac
spcd_split
spcd_txt_locales_echo
}
# ╭──────┬─────╮