Compare commits

..

No commits in common. "5d9100a39b516468a28df3c000d22b241cf5fbd0" and "05ccc94e9cd4ac86d98cfa7ab19107496e19c72b" have entirely different histories.

2 changed files with 94 additions and 121 deletions

View file

@ -221,7 +221,6 @@ Handle project workflows in a unified way:
#### Shell #### Shell
* command to echo & run
* comment * comment
* handle errors * handle errors
* packages * packages

View file

@ -377,6 +377,86 @@ spcd_txt_get() {
esac esac
} }
spcd_txt_locale() {
local action="${1}"
local locale="${2}"
set -- \
"LANG" \
"LC_CTYPE" \
"LC_NUMERIC" \
"LC_TIME" \
"LC_COLLATE" \
"LC_MONETARY" \
"LC_MESSAGES" \
"LC_PAPER" \
"LC_NAME" \
"LC_ADDRESS" \
"LC_TELEPHONE" \
"LC_MEASUREMENT" \
"LC_IDENTIFICATION"
local value name
if [ "${action}" = "set" ]; then
if [ -n "${locale}" ]; then
value="${locale}"
else
value="${_SPCD_TXT_LOCALE_DEFAULT}"
fi
value="${value}.${_SPCD_TXT_CHARSET}"
fi
for name in "${@}"; do
case "${action}" in
"list") spcd_os_printenv "${name}" ;;
"set") export "${name}=${value}" ;;
*) ;;
esac
done
if [ "${action}" = "set" ]; then
spcd_txt_locale "list"
fi
}
spcd_txt_locales_echo() {
spcd_os_printenv "LANGUAGE"
locale --all-locales
}
spcd_txt_locales() {
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}
"
;;
*) ;;
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
}
# ╭──────╮ # ╭──────╮
# │ step │ # │ step │
# ╰──────╯ # ╰──────╯
@ -861,125 +941,6 @@ spcd_query_package() {
esac esac
} }
spcd_txt_locale() {
local action="${1}"
local chosen="${2}"
set -- \
"LANG" \
"LC_CTYPE" \
"LC_NUMERIC" \
"LC_TIME" \
"LC_COLLATE" \
"LC_MONETARY" \
"LC_MESSAGES"
case "${SPCD_OS_ID}" in
"${SPCD_OS_ALPINE}") ;;
*)
set -- \
"${@}" \
"LANGUAGE" \
"LC_PAPER" \
"LC_NAME" \
"LC_ADDRESS" \
"LC_TELEPHONE" \
"LC_MEASUREMENT" \
"LC_IDENTIFICATION"
;;
esac
local name
case "${action}" in
"list")
if ! locale; then
for name in "${@}"; do
spcd_os_printenv "${name}"
done
fi
;;
"set")
spcd_txt_locale "list"
spcd_split
local locale long
if [ -n "${chosen}" ]; then
locale="${chosen}"
else
locale="${_SPCD_TXT_LOCALE_DEFAULT}"
fi
long="${locale}.${_SPCD_TXT_CHARSET}"
for name in "${@}"; do
if [ "${name}" != "LANGUAGE" ]; then
export "${name}=${long}"
else
export "${name}=$(spcd_txt_locales language "${chosen}")"
fi
done
spcd_split
spcd_txt_locale "list"
;;
*) ;;
esac
}
spcd_txt_locales() {
local action="${1}"
local chosen="${2}"
set -- \
"${SPCD_TXT_LOCALE_ENGLISH}" \
"${SPCD_TXT_LOCALE_FRENCH}"
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_install_package "locales"
;;
"${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}:${name}"
else
text="${name}"
fi
fi
done
;;
"list")
if ! locale --all-locales; then
echo "No locales yet!"
fi
;;
*) ;;
esac
}
# ╭──────┬─────╮ # ╭──────┬─────╮
# │ step │ dns │ # │ step │ dns │
# ╰──────┴─────╯ # ╰──────┴─────╯
@ -1287,7 +1248,20 @@ spcd_step__packages_verify_https() {
spcd_step__packages_install_locales() { spcd_step__packages_install_locales() {
spcd_step "Install locales" spcd_step "Install locales"
spcd_txt_locales "install" case "${SPCD_PM}" in
"${SPCD_PM_APK}") spcd_install_package "musl-locales" ;;
"${SPCD_PM_APT}")
spcd_txt_locales "locale.gen"
spcd_install_package "locales"
;;
"${SPCD_PM_DNF}")
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 "set" "${SPCD_TXT_LOCALE}" spcd_txt_locale "set" "${SPCD_TXT_LOCALE}"
} }