rewrite locales
This commit is contained in:
parent
dc51f1eba6
commit
1773608215
1 changed files with 48 additions and 30 deletions
|
@ -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
|
||||
}
|
||||
|
||||
# ╭──────┬─────╮
|
||||
|
|
Loading…
Reference in a new issue