Rerun China installs in a console that draws Chinese and show the installer in Chinese
This commit is contained in:
1 parent
45b31ae98c
commit
48471b25c1
8 files changed
+373
-109
No files matched your search
@@ -273,6 +273,12 @@ mkdir -p "$omarchy_share"
|
||||
printf 'logo bottom row%*s\n' 66 ''
|
||||
} >"$omarchy_share/logo.txt"
|
||||
|
||||
# The ISO vendors the runtime's setup form; the dashboard only needs its text lookup.
|
||||
cat >"$work/setup-form.sh" <<'FORM'
|
||||
declare -gA OMARCHY_ZH=()
|
||||
omarchy_text() { local text=$1; shift; printf -- "$text" "$@"; }
|
||||
FORM
|
||||
|
||||
run_dashboard() {
|
||||
local install_log="$1"
|
||||
|
||||
@@ -284,7 +290,7 @@ run_dashboard() {
|
||||
"error": "Pacstrap failed. See /var/log/archinstall.log"}]}
|
||||
STATE
|
||||
: >"$screen"
|
||||
script -qefc "stty rows 40 cols 120; PATH='$stubs:$PATH' OMARCHY_PATH='$omarchy_share' OMARCHY_UI_INTERACTIVE=no OMARCHY_UI_FAILURE_ACTION=exit OMARCHY_FAILURE_TAIL_LOG='$install_log' '$DASHBOARD' '$install_log' '$state_file' -- bash -c 'exit 1'" \
|
||||
script -qefc "stty rows 40 cols 120; PATH='$stubs:$PATH' OMARCHY_PATH='$omarchy_share' SETUP_FORM='$work/setup-form.sh' OMARCHY_UI_INTERACTIVE=no OMARCHY_UI_FAILURE_ACTION=exit OMARCHY_FAILURE_TAIL_LOG='$install_log' '$DASHBOARD' '$install_log' '$state_file' -- bash -c 'exit 1'" \
|
||||
"$screen" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# China installs read in Chinese: every text the configurator and the install
|
||||
# dashboard pass to omarchy_text needs an OMARCHY_ZH entry, or it shows in English.
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
ROOT=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/../.." && pwd)
|
||||
SETUP_FORM="${OMARCHY_SOURCE:-$ROOT/../omarchy}/install/provisioning/setup-form.sh"
|
||||
|
||||
fail() {
|
||||
printf 'not ok - %s\n' "$1"
|
||||
[[ -z ${2:-} ]] || printf '%s\n' "$2" | sed 's/^/# /'
|
||||
exit 1
|
||||
}
|
||||
|
||||
if [[ ! -r $SETUP_FORM ]]; then
|
||||
printf 'ok - # skip the setup form is not checked out next to this repo (set OMARCHY_SOURCE)\n'
|
||||
exit 0
|
||||
fi
|
||||
|
||||
source "$SETUP_FORM"
|
||||
for file in configs/airootfs/root/configurator configs/airootfs/usr/local/bin/omarchy-install-dashboard; do
|
||||
eval "$(sed -n '/^OMARCHY_ZH+=(/,/^)/p' "$ROOT/$file")"
|
||||
done
|
||||
|
||||
mapfile -t texts < <(
|
||||
grep -ho 'omarchy_text "[^"$]*"' "$ROOT/configs/airootfs/root/configurator" "$ROOT/configs/airootfs/usr/local/bin/omarchy-install-dashboard" |
|
||||
sed 's/^omarchy_text "//; s/"$//' | sort -u
|
||||
)
|
||||
((${#texts[@]} > 50)) || fail "the installer routes its text through omarchy_text" "found ${#texts[@]}"
|
||||
for text in "${texts[@]}"; do
|
||||
[[ -n ${OMARCHY_ZH[$text]:-} ]] || fail "every installer text has a Chinese entry" "missing: $text"
|
||||
done
|
||||
printf 'ok - every installer and dashboard text has a Chinese entry\n'
|
||||
|
||||
for action in "View full log" "Drop to shell" "Reboot" "Power off" "Upload log for support" "Global" "China"; do
|
||||
[[ -n ${OMARCHY_ZH[$action]:-} ]] || fail "labels passed through variables have Chinese entries" "missing: $action"
|
||||
done
|
||||
printf 'ok - labels passed through variables have Chinese entries\n'
|
||||
|
||||
[[ $(OMARCHY_INSTALL_LANG=zh omarchy_text "Confirm overwriting %s" /dev/vda) == "确认覆盖 /dev/vda" ]] ||
|
||||
fail "Chinese text keeps its printf arguments"
|
||||
[[ $(omarchy_text "Confirm overwriting %s" /dev/vda) == "Confirm overwriting /dev/vda" ]] ||
|
||||
fail "English stays the default"
|
||||
printf 'ok - omarchy_text formats Chinese and English alike\n'
|
||||
Reference in new issue
Block a user