Compare commits

..

10 commits

Author SHA1 Message Date
5d9100a39b
locale/language
Some checks failed
/ arch (push) Successful in 2m44s
/ alpine (push) Successful in 1m45s
/ fedora (push) Successful in 12m51s
/ opensuse (push) Successful in 3m43s
/ alma (push) Successful in 13m6s
/ rocky (push) Successful in 12m19s
/ ubuntu (push) Successful in 6m29s
/ debian (push) Failing after 3m25s
2024-09-04 15:29:43 +02:00
aac5e65650
fix locales 2024-09-04 15:27:21 +02:00
1773608215
rewrite locales 2024-09-04 15:22:03 +02:00
dc51f1eba6
mv 2024-09-04 14:44:39 +02:00
44f68bcca2
transfer language 2024-09-04 14:41:43 +02:00
56b9215ef3
command 2024-09-04 14:26:17 +02:00
84c0885f1f
locale/alpine 2024-09-04 14:25:32 +02:00
d592c30ffd
mv 2024-09-04 14:23:15 +02:00
194ff1b177
rewrite locale 2024-09-04 14:21:28 +02:00
e42561f3c1
locale/split 2024-09-04 14:06:14 +02:00
2 changed files with 121 additions and 94 deletions

View file

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

View file

@ -377,86 +377,6 @@ spcd_txt_get() {
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 │
# ╰──────╯
@ -941,6 +861,125 @@ spcd_query_package() {
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 │
# ╰──────┴─────╯
@ -1248,20 +1287,7 @@ spcd_step__packages_verify_https() {
spcd_step__packages_install_locales() {
spcd_step "Install locales"
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_locales "install"
spcd_txt_locale "set" "${SPCD_TXT_LOCALE}"
}