Split language from region: omarchy-language and Setup > Language own LANG
omarchy-region and install/config/region.sh no longer touch the locale; both logout prompts are worded through omarchy-text.
This commit is contained in:
1 parent
1824bc3066
commit
199a7f23fc
13 files changed
+157
-46
No files matched your search
@@ -10,11 +10,12 @@ trap 'rm -rf "$test_tmp"' EXIT
|
||||
root="$test_tmp/root" sandbox="$test_tmp/omarchy" calls="$test_tmp/calls"
|
||||
mkdir -p "$root/etc/pacman.d" "$sandbox/bin" "$sandbox/install/config" "$sandbox/default/regions" "$test_tmp/bin" "$test_tmp/home"
|
||||
cp -r "$ROOT/default/regions/cn" "$sandbox/default/regions/"
|
||||
mkdir -p "$sandbox/shell/Commons" && cp "$ROOT/shell/Commons/I18nZh.js" "$sandbox/shell/Commons/"
|
||||
rewrite() { sed -e "s|/etc/|$root/etc/|g" -e "s| /\\.cargo/| $root/.cargo/|g" "$1" >"$2"; chmod +x "$2"; }
|
||||
rewrite "$ROOT/install/config/region.sh" "$sandbox/install/config/region.sh"
|
||||
rewrite "$ROOT/bin/omarchy-region" "$sandbox/bin/omarchy-region"
|
||||
|
||||
for command in omarchy-refresh-pacman locale-gen omarchy-setup-claude-api omarchy-system-logout pacman-key pacman omarchy-apply-pacman; do
|
||||
for command in omarchy-refresh-pacman omarchy-setup-claude-api omarchy-system-logout pacman-key pacman omarchy-apply-pacman; do
|
||||
printf '#!/bin/bash\necho "%s $*" >>"%s"\n' "$command" "$calls" >"$test_tmp/bin/$command"
|
||||
done
|
||||
printf '#!/bin/bash\necho "omarchy-update-pacman $*" >>"%s"\n[[ -z ${STUB_UPDATE_FAIL:-} ]]\n' "$calls" >"$test_tmp/bin/omarchy-update-pacman"
|
||||
@@ -22,17 +23,17 @@ printf '#!/bin/bash\necho "${STUB_CHANNEL:-stable}"\n' >"$test_tmp/bin/omarchy-v
|
||||
printf '#!/bin/bash\n[[ $1 == env ]] && shift\nexec env "$@"\n' >"$test_tmp/bin/sudo"
|
||||
printf '#!/bin/bash\necho "gum $*" >>"%s"\nexit "${GUM_ANSWER:-1}"\n' "$calls" >"$test_tmp/bin/gum"
|
||||
chmod +x "$test_tmp/bin"/*
|
||||
ln -s "$ROOT/bin/omarchy-text" "$test_tmp/bin/omarchy-text"
|
||||
mkdir -p "$test_tmp/tmp"
|
||||
export PATH="$test_tmp/bin:$sandbox/bin:$PATH" OMARCHY_PATH="$sandbox" HOME="$test_tmp/home" TMPDIR="$test_tmp/tmp"
|
||||
switch_calls() { sed "s|$test_tmp/tmp/[^/ ]*|RENDERED|g" "$calls"; }
|
||||
|
||||
printf '#zh_CN.UTF-8 UTF-8\nen_US.UTF-8 UTF-8\n' >"$root/etc/locale.gen"
|
||||
printf 'LANG=en_US.UTF-8\n' >"$root/etc/locale.conf"
|
||||
|
||||
omarchy-region cn >/dev/null
|
||||
[[ $(omarchy-region) == "China" && $(<"$root/etc/omarchy/region") == "cn" && $(<"$root/etc/locale.conf") == "LANG=zh_CN.UTF-8" ]] ||
|
||||
fail "switching to China records cn and sets the language"
|
||||
[[ $(switch_calls) == $'omarchy-update-pacman -Syu --noconfirm\nlocale-gen \nomarchy-apply-pacman --render stable RENDERED\npacman --config RENDERED/pacman.conf -Sy --noconfirm --needed archlinuxcn-keyring\npacman-key --populate archlinuxcn\nomarchy-refresh-pacman stable' ]] ||
|
||||
[[ $(omarchy-region) == "China" && $(<"$root/etc/omarchy/region") == "cn" && $(<"$root/etc/locale.conf") == "LANG=en_US.UTF-8" ]] ||
|
||||
fail "switching to China records cn and leaves the language alone"
|
||||
[[ $(switch_calls) == $'omarchy-update-pacman -Syu --noconfirm\nomarchy-apply-pacman --render stable RENDERED\npacman --config RENDERED/pacman.conf -Sy --noconfirm --needed archlinuxcn-keyring\npacman-key --populate archlinuxcn\nomarchy-refresh-pacman stable' ]] ||
|
||||
fail "China upgrades, trusts ArchLinuxCN through the rendered cn config, then refreshes" "$(switch_calls)"
|
||||
[[ -z $(ls -A "$test_tmp/tmp") ]] || fail "the rendered config is removed"
|
||||
pass "switching to China trusts ArchLinuxCN before the refresh upgrades through it"
|
||||
@@ -44,11 +45,11 @@ pass "switching to China again keeps the channel"
|
||||
|
||||
: >"$calls"
|
||||
omarchy-region global >/dev/null
|
||||
[[ $(omarchy-region) == "Global" && ! -e $root/etc/omarchy/region && $(<"$root/etc/locale.conf") == "LANG=en_US.UTF-8" ]] ||
|
||||
fail "switching to Global removes the region and restores English"
|
||||
[[ $(omarchy-region) == "Global" && ! -e $root/etc/omarchy/region ]] ||
|
||||
fail "switching to Global removes the region"
|
||||
[[ $(<"$calls") == $'omarchy-refresh-pacman stable\nomarchy-setup-claude-api --remove' ]] ||
|
||||
fail "Global refreshes pacman back to the channel defaults and removes the Claude API setup" "$(<"$calls")"
|
||||
pass "switching to Global restores the channel's pacman defaults and English, removes the Claude API setup"
|
||||
pass "switching to Global restores the channel's pacman defaults and removes the Claude API setup"
|
||||
|
||||
if output=$(omarchy-region mars 2>&1); then
|
||||
fail "an unknown region is refused" "$output"
|
||||
@@ -69,13 +70,13 @@ pass "a failed switch to China leaves the machine Global"
|
||||
|
||||
grep -q '^gum' "$calls" && fail "a switch without a terminal asks nothing" "$(<"$calls")"
|
||||
: >"$calls"
|
||||
output=$(GUM_ANSWER=1 script -qec "omarchy-region cn" /dev/null)
|
||||
grep -qxF 'gum confirm --affirmative 立即注销 --negative 稍后 立即注销,切换到中文界面和国内镜像?' "$calls" ||
|
||||
fail "switching to China offers to log out, in Chinese" "$(<"$calls")"
|
||||
[[ $output == *"区域已设为中国。重新登录后切换到中文界面和国内镜像。"* ]] && ! grep -q '^omarchy-system-logout' "$calls" ||
|
||||
output=$(LANG=zh_CN.UTF-8 GUM_ANSWER=1 script -qec "omarchy-region cn" /dev/null)
|
||||
grep -qxF 'gum confirm --affirmative 立即注销 --negative 稍后 立即注销以切换开发工具镜像?' "$calls" ||
|
||||
fail "a Chinese session offers to log out in Chinese" "$(<"$calls")"
|
||||
[[ $output == *"重新登录后切换开发工具镜像。"* ]] && ! grep -q '^omarchy-system-logout' "$calls" ||
|
||||
fail "declining the logout leaves a reminder and the session" "$output"
|
||||
: >"$calls"
|
||||
GUM_ANSWER=0 script -qec "omarchy-region global" /dev/null >/dev/null
|
||||
grep -qxF 'gum confirm --affirmative Log out now --negative Later Log out now to switch to English and the global mirrors?' "$calls" &&
|
||||
grep -qx 'omarchy-system-logout ' "$calls" || fail "switching to Global offers to log out in English and logs out on yes" "$(<"$calls")"
|
||||
pass "a switch in a terminal offers to log out in the new region's language"
|
||||
LANG=en_US.UTF-8 GUM_ANSWER=0 script -qec "omarchy-region global" /dev/null >/dev/null
|
||||
grep -qxF 'gum confirm --affirmative Log out now --negative Later Log out now to switch the developer mirrors?' "$calls" &&
|
||||
grep -qx 'omarchy-system-logout ' "$calls" || fail "an English session offers to log out in English and logs out on yes" "$(<"$calls")"
|
||||
pass "a switch in a terminal offers to log out in the session's language"
|
||||
Reference in new issue
Block a user