diff --git a/AGENTS.md b/AGENTS.md index ce776e71..27eeedf8 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -99,8 +99,9 @@ Exceptions are allowed for migration and package-helper scripts where the helper # Region - `/etc/omarchy/region` holds `cn`; no file means Global. `omarchy-region` prints the region and switches it (`omarchy region cn|global`); the profile lives in `default/regions/cn/`, its contract in `docs/regions.md`, user-facing docs in `manual/52-china.md`. -- `install/config/region.sh` is the one system leaf for both the ISO install (the `/etc/omarchy/region` marker the installer derives from the timezone) and the runtime switch (`OMARCHY_REGION`): region file, the profile drop-ins it symlinks, and the locale. Input methods are not part of a region: the installer's keyboard choice and `omarchy-setup-input` own them (`docs/input-methods.md`). +- `install/config/region.sh` is the one system leaf for both the ISO install (the `/etc/omarchy/region` marker the installer derives from the timezone) and the runtime switch (`OMARCHY_REGION`): the region file and the profile drop-ins it symlinks. Input methods are not part of a region: the installer's keyboard choice and `omarchy-setup-input` own them (`docs/input-methods.md`). - `omarchy-apply-pacman` renders pacman for every caller: the channel templates, the profile's `pacman/mirrorlist-.prepend` ahead of the mirrorlist, and its `pacman.conf.append`. Nothing in `omarchy update` or migrations may change the region or `/etc/locale.conf`. +- Language is separate from region: `omarchy-language en|zh` (Setup > Language) owns `LANG` in `/etc/locale.conf`, the installer sets it from its first screen, and nothing keyed by region touches it. - China-only menu rows carry `"when":"[[ \"$(omarchy-region)\" == \"China\" ]]"` on every row, not only the submenu, because search checks each row's own guard. - Chinese menu labels live in `default/omarchy/omarchy-menu.zh-cn.jsonc`, merged when `LANG` starts with `zh_CN`; give a new menu row with translatable words a label there. - Shell text goes through `I18n.tr("English %1", arg)` from `qs.Commons`, with its Chinese in `shell/Commons/I18nZh.js` keyed by the English. Notifications and OSD messages are worded by their sender with `omarchy-text "English %1" "$arg"` (Python: `text()`, QML: `I18n.tr`), which reads the same table; the shell shows them as given, so user text is never translated. `test/shell.d/shell-i18n-test.sh` fails on a missing entry. diff --git a/bin/omarchy b/bin/omarchy index 0649f0a5..d91be6b4 100755 --- a/bin/omarchy +++ b/bin/omarchy @@ -58,6 +58,7 @@ GROUP_DESCRIPTIONS[hw]="Hardware detection and controls" GROUP_DESCRIPTIONS[hyprland]="Hyprland window, monitor, and toggle controls" GROUP_DESCRIPTIONS[install]="Optional software installers" GROUP_DESCRIPTIONS[installed]="Installed optional service checks" +GROUP_DESCRIPTIONS[language]="System language" GROUP_DESCRIPTIONS[launch]="Application launchers" GROUP_DESCRIPTIONS[menu]="Omarchy menu commands" GROUP_DESCRIPTIONS[migrate]="Migration runner" diff --git a/bin/omarchy-language b/bin/omarchy-language new file mode 100755 index 00000000..d39688b9 --- /dev/null +++ b/bin/omarchy-language @@ -0,0 +1,42 @@ +#!/bin/bash + +# omarchy:summary=Show or switch the system language between English and Simplified Chinese +# omarchy:args=[en|zh] +# omarchy:examples=omarchy language | omarchy language zh +# omarchy:requires-sudo=true + +set -euo pipefail + +locale_conf=/etc/locale.conf + +if (($# == 0)); then + sed -n 's/^LANG=//p' "$locale_conf" + exit 0 +fi + +case ${1:-} in +en) lang=en_US.UTF-8 ;; +zh) lang=zh_CN.UTF-8 ;; +*) + echo "Usage: omarchy-language [en|zh]" >&2 + exit 1 + ;; +esac + +sudo sed -i "s/^#\(${lang/./\\.} UTF-8\)/\1/" /etc/locale.gen +sudo locale-gen +if grep -q '^LANG=' "$locale_conf"; then + sudo sed -i "s/^LANG=.*/LANG=$lang/" "$locale_conf" +else + echo "LANG=$lang" | sudo tee -a "$locale_conf" >/dev/null +fi + +# The language reaches only a new session, so offer one in the new language. +prompt=$(LANG=$lang omarchy-text "Log out now to switch the language?") +log_out=$(LANG=$lang omarchy-text "Log out now") +later=$(LANG=$lang omarchy-text "Later") +if [[ -t 0 && -t 1 ]] && gum confirm --affirmative "$log_out" --negative "$later" "$prompt" 2>&1; then + omarchy-system-logout +else + LANG=$lang omarchy-text "Log back in to switch the language." +fi diff --git a/bin/omarchy-region b/bin/omarchy-region index 86994b6e..b9eca979 100755 --- a/bin/omarchy-region +++ b/bin/omarchy-region @@ -50,16 +50,9 @@ else omarchy-setup-claude-api --remove fi -# The language and the developer mirrors reach only a new session, so offer one in the new language. -if [[ $1 == "cn" ]]; then - prompt="立即注销,切换到中文界面和国内镜像?" log_out="立即注销" later="稍后" - reminder="区域已设为中国。重新登录后切换到中文界面和国内镜像。" -else - prompt="Log out now to switch to English and the global mirrors?" log_out="Log out now" later="Later" - reminder="Region set to Global. Log back in to switch to English and the global mirrors." -fi -if [[ -t 0 && -t 1 ]] && gum confirm --affirmative "$log_out" --negative "$later" "$prompt" 2>&1; then +# The developer mirrors reach only a new session, so offer one. +if [[ -t 0 && -t 1 ]] && gum confirm --affirmative "$(omarchy-text "Log out now")" --negative "$(omarchy-text "Later")" "$(omarchy-text "Log out now to switch the developer mirrors?")" 2>&1; then omarchy-system-logout else - echo "$reminder" + omarchy-text "Log back in to switch the developer mirrors." fi diff --git a/default/omarchy/omarchy-menu.jsonc b/default/omarchy/omarchy-menu.jsonc index 7394ab0b..7a56bb71 100644 --- a/default/omarchy/omarchy-menu.jsonc +++ b/default/omarchy/omarchy-menu.jsonc @@ -177,6 +177,9 @@ "setup.default.editor.helix": {"icon":"","label":"Helix","checked":"[[ \"$(omarchy-default-editor)\" == \"helix\" ]]","action":"omarchy-default-editor helix"}, "setup.default.editor.vim": {"icon":"","label":"Vim","checked":"[[ \"$(omarchy-default-editor)\" == \"vim\" ]]","action":"omarchy-default-editor vim"}, "setup.default.editor.emacs": {"icon":" ","label":"Emacs","checked":"[[ \"$(omarchy-default-editor)\" == \"emacs\" ]]","action":"omarchy-default-editor emacs"}, + "setup.language": {"icon":"󰗊","label":"Language"}, + "setup.language.en": {"icon":"󰗊","label":"English","checked":"[[ \"$(omarchy-language)\" == \"en_US.UTF-8\" ]]","action":"omarchy-launch-floating-terminal-with-presentation 'omarchy-language en'"}, + "setup.language.zh": {"icon":"󰗊","label":"简体中文","checked":"[[ \"$(omarchy-language)\" == \"zh_CN.UTF-8\" ]]","action":"omarchy-launch-floating-terminal-with-presentation 'omarchy-language zh'"}, "setup.region": {"icon":"󰇧","label":"Region"}, "setup.region.global": {"icon":"󰖟","label":"Global","checked":"[[ \"$(omarchy-region)\" == \"Global\" ]]","action":"omarchy-launch-floating-terminal-with-presentation 'omarchy-region global'"}, "setup.region.china": {"icon":"󰈻","label":"China","checked":"[[ \"$(omarchy-region)\" == \"China\" ]]","action":"omarchy-launch-floating-terminal-with-presentation 'omarchy-region cn'"}, diff --git a/default/omarchy/omarchy-menu.zh-cn.jsonc b/default/omarchy/omarchy-menu.zh-cn.jsonc index 4d6ce96f..1242e5da 100644 --- a/default/omarchy/omarchy-menu.zh-cn.jsonc +++ b/default/omarchy/omarchy-menu.zh-cn.jsonc @@ -89,6 +89,7 @@ "setup.keybindings": {"label":"快捷键"}, "setup.input": {"label":"输入设备"}, "setup.input-method": {"label":"输入语言"}, + "setup.language": {"label":"语言"}, "setup.network": {"label":"网络"}, "setup.network.dns.custom": {"label":"自定义"}, "setup.network.qr": {"label":"二维码"}, diff --git a/install/config/region.sh b/install/config/region.sh index 54a09a0e..64b6f40e 100644 --- a/install/config/region.sh +++ b/install/config/region.sh @@ -14,7 +14,6 @@ region=${OMARCHY_REGION:-$region} case $region in global) rm -f /etc/omarchy/region - sed -i 's/^LANG=zh_CN\.UTF-8$/LANG=en_US.UTF-8/' /etc/locale.conf for link in "${cn_links[@]}"; do read -r _ target <<<"$link" if [[ -L $target && $(readlink "$target") == */default/regions/cn/* ]]; then @@ -37,13 +36,6 @@ cn) mkdir -p "${target%/*}" ln -sfn "$OMARCHY_PATH/default/regions/cn/$source" "$target" done - sed -i 's/^#\(zh_CN\.UTF-8 UTF-8\)/\1/' /etc/locale.gen - locale-gen - if grep -q '^LANG=' /etc/locale.conf; then - sed -i 's/^LANG=.*/LANG=zh_CN.UTF-8/' /etc/locale.conf - else - echo LANG=zh_CN.UTF-8 >>/etc/locale.conf - fi ;; *) echo "Unknown region: $region" >&2 diff --git a/shell/Commons/I18nZh.js b/shell/Commons/I18nZh.js index 75f9c3d4..30f45c40 100644 --- a/shell/Commons/I18nZh.js +++ b/shell/Commons/I18nZh.js @@ -610,5 +610,11 @@ var table = { "Click to switch input language": "点击切换输入语言", "Ctrl + Shift + Space to toggle input": "Ctrl + Shift + Space 切换输入", "Japanese: type a word, then Space twice for character choices": "日语:输入词语后按两次空格选字", - "Right-click to switch keyboard layout": "右键切换键盘布局" + "Right-click to switch keyboard layout": "右键切换键盘布局", + "Log out now": "立即注销", + "Later": "稍后", + "Log out now to switch the language?": "立即注销以切换语言?", + "Log back in to switch the language.": "重新登录后切换语言。", + "Log out now to switch the developer mirrors?": "立即注销以切换开发工具镜像?", + "Log back in to switch the developer mirrors.": "重新登录后切换开发工具镜像。" } diff --git a/shell/plugins/menu/MenuModel.js b/shell/plugins/menu/MenuModel.js index db871242..29e4784f 100644 --- a/shell/plugins/menu/MenuModel.js +++ b/shell/plugins/menu/MenuModel.js @@ -414,7 +414,8 @@ var GUARD_READERS = [ "omarchy-default-editor", "omarchy-default-terminal", "omarchy-dns", - "omarchy-region" + "omarchy-region", + "omarchy-language" ] // Package and command presence account for most of what the guards ask, and diff --git a/test/shell.d/language-test.sh b/test/shell.d/language-test.sh new file mode 100755 index 00000000..6d1e61d6 --- /dev/null +++ b/test/shell.d/language-test.sh @@ -0,0 +1,64 @@ +#!/bin/bash + +set -euo pipefail + +source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh" + +test_tmp=$(mktemp -d) +trap 'rm -rf "$test_tmp"' EXIT + +root="$test_tmp/root" sandbox="$test_tmp/omarchy" calls="$test_tmp/calls" +mkdir -p "$root/etc" "$sandbox/bin" "$sandbox/shell/Commons" "$test_tmp/bin" +cp "$ROOT/shell/Commons/I18nZh.js" "$sandbox/shell/Commons/" +sed "s|/etc/|$root/etc/|g" "$ROOT/bin/omarchy-language" >"$sandbox/bin/omarchy-language" +for command in locale-gen omarchy-system-logout; do + printf '#!/bin/bash\necho "%s $*" >>"%s"\n' "$command" "$calls" >"$test_tmp/bin/$command" +done +printf '#!/bin/bash\nexec "$@"\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"/* "$sandbox/bin/omarchy-language" +ln -s "$ROOT/bin/omarchy-text" "$test_tmp/bin/omarchy-text" +export PATH="$test_tmp/bin:$sandbox/bin:$PATH" OMARCHY_PATH="$sandbox" LANG=en_US.UTF-8 + +printf '#zh_CN.UTF-8 UTF-8\nen_US.UTF-8 UTF-8\n' >"$root/etc/locale.gen" +printf 'LANG=en_US.UTF-8\nLC_TIME=en_DK.UTF-8\n' >"$root/etc/locale.conf" + +[[ $(omarchy-language) == "en_US.UTF-8" ]] || fail "omarchy-language prints the system LANG" +pass "omarchy-language prints the system LANG" + +: >"$calls" +output=$(omarchy-language zh) +[[ $(<"$root/etc/locale.gen") == $'zh_CN.UTF-8 UTF-8\nen_US.UTF-8 UTF-8' ]] || fail "Chinese enables zh_CN in locale.gen" +[[ $(<"$root/etc/locale.conf") == $'LANG=zh_CN.UTF-8\nLC_TIME=en_DK.UTF-8' ]] || fail "Chinese sets LANG and keeps other settings" "$(<"$root/etc/locale.conf")" +[[ $(<"$calls") == "locale-gen " ]] || fail "Chinese generates the locale and asks nothing without a terminal" "$(<"$calls")" +[[ $output == "重新登录后切换语言。" ]] || fail "Chinese reminds to log back in, in Chinese" "$output" +pass "switching to Chinese generates zh_CN, sets LANG, and reminds in Chinese" + +sed -i 's/^en_US/#en_US/' "$root/etc/locale.gen" +output=$(omarchy-language en) +[[ $(<"$root/etc/locale.gen") == $'zh_CN.UTF-8 UTF-8\nen_US.UTF-8 UTF-8' ]] || fail "English enables en_US in locale.gen" +[[ $(<"$root/etc/locale.conf") == $'LANG=en_US.UTF-8\nLC_TIME=en_DK.UTF-8' ]] || fail "English sets LANG back" "$(<"$root/etc/locale.conf")" +[[ $output == "Log back in to switch the language." ]] || fail "English reminds in English" "$output" +pass "switching to English generates en_US and sets LANG" + +printf 'LC_TIME=en_DK.UTF-8\n' >"$root/etc/locale.conf" +omarchy-language zh >/dev/null +[[ $(<"$root/etc/locale.conf") == $'LC_TIME=en_DK.UTF-8\nLANG=zh_CN.UTF-8' ]] || fail "a locale.conf without LANG gains one" "$(<"$root/etc/locale.conf")" +pass "a locale.conf without LANG gains one" + +before=$(<"$root/etc/locale.conf") +if output=$(omarchy-language fr 2>&1); then + fail "an unknown language is refused" "$output" +fi +[[ $output == "Usage: omarchy-language [en|zh]" && $(<"$root/etc/locale.conf") == "$before" ]] || fail "a refused language changes nothing" "$output" +pass "an unknown language is refused and changes nothing" + +: >"$calls" +GUM_ANSWER=0 script -qec "omarchy-language en" /dev/null >/dev/null +grep -qxF 'gum confirm --affirmative Log out now --negative Later Log out now to switch the language?' "$calls" && + grep -qx 'omarchy-system-logout ' "$calls" || fail "a terminal switch offers to log out and logs out on yes" "$(<"$calls")" +: >"$calls" +GUM_ANSWER=1 script -qec "omarchy-language zh" /dev/null >/dev/null +grep -qxF 'gum confirm --affirmative 立即注销 --negative 稍后 立即注销以切换语言?' "$calls" && ! grep -q '^omarchy-system-logout' "$calls" || + fail "a terminal switch asks in the new language and keeps the session on no" "$(<"$calls")" +pass "a terminal switch offers to log out in the new language" diff --git a/test/shell.d/menu-test.sh b/test/shell.d/menu-test.sh index b9fa73d4..402089d2 100644 --- a/test/shell.d/menu-test.sh +++ b/test/shell.d/menu-test.sh @@ -305,6 +305,15 @@ assert( && defaultById['setup.region.china'].action.includes('omarchy-region cn'), 'menu offers Global and China under Setup > Region' ) +const languageEntries = defaultItems.filter(item => item.parent === 'setup.language') +assert( + languageEntries.map(item => item.id).join('\0') === 'setup.language.en\0setup.language.zh' + && defaultById['setup.language.en'].checked.includes('== \"en_US.UTF-8\"') + && defaultById['setup.language.zh'].checked.includes('== \"zh_CN.UTF-8\"') + && defaultById['setup.language.en'].action.includes('omarchy-language en') + && defaultById['setup.language.zh'].action.includes('omarchy-language zh'), + 'menu offers English and Simplified Chinese under Setup > Language' +) // Software you already have keeps its place in Install, dimmed rather than // dropped, so the list reads as a catalog of what Omarchy can install. // Chromium Account is the sole Install row with anything left to hide for, so diff --git a/test/shell.d/region-switch-test.sh b/test/shell.d/region-switch-test.sh index b9bf9869..49534542 100755 --- a/test/shell.d/region-switch-test.sh +++ b/test/shell.d/region-switch-test.sh @@ -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" diff --git a/test/shell.d/region-test.sh b/test/shell.d/region-test.sh index 4ca6a846..38162fd6 100755 --- a/test/shell.d/region-test.sh +++ b/test/shell.d/region-test.sh @@ -44,10 +44,9 @@ printf 'LANG=en_US.UTF-8\nLC_TIME=en_DK.UTF-8\n' >"$root/etc/locale.conf" : >"$calls" OMARCHY_REGION=cn bash -e "$region_setup" [[ $(<"$root/etc/omarchy/region") == "cn" ]] || fail "install records the China region as cn" -[[ $(<"$calls") == "locale-gen " ]] || fail "China generates the Chinese locale" "$(<"$calls")" -[[ $(<"$root/etc/locale.gen") == $'zh_CN.UTF-8 UTF-8\nen_US.UTF-8 UTF-8' ]] || fail "China enables zh_CN in locale.gen" -[[ $(<"$root/etc/locale.conf") == $'LANG=zh_CN.UTF-8\nLC_TIME=en_DK.UTF-8' ]] || fail "China sets LANG and keeps other locale settings" "$(<"$root/etc/locale.conf")" -pass "install records the China region and sets the Chinese locale" +[[ ! -s $calls && $(<"$root/etc/locale.gen") == $'#zh_CN.UTF-8 UTF-8\nen_US.UTF-8 UTF-8' && $(<"$root/etc/locale.conf") == $'LANG=en_US.UTF-8\nLC_TIME=en_DK.UTF-8' ]] || + fail "China leaves the language alone" "$(<"$root/etc/locale.conf")" +pass "install records the China region and leaves the language alone" for link in "environment.conf etc/environment.d/90-omarchy-china.conf" "cargo.toml .cargo/config.toml" "gemrc etc/gemrc"; do read -r source target <<<"$link" @@ -58,12 +57,10 @@ pass "China links the developer mirror drop-ins" : >"$calls" OMARCHY_REGION=global bash -e "$region_setup" [[ ! -e $root/etc/omarchy/region ]] || fail "install records Global by leaving no region file" -[[ $(<"$root/etc/locale.conf") == $'LANG=en_US.UTF-8\nLC_TIME=en_DK.UTF-8' ]] || fail "Global turns a Chinese LANG back to English" "$(<"$root/etc/locale.conf")" -printf 'LANG=de_DE.UTF-8\n' >"$root/etc/locale.conf" +printf 'LANG=zh_CN.UTF-8\n' >"$root/etc/locale.conf" OMARCHY_REGION=global bash -e "$region_setup" -[[ $(<"$root/etc/locale.conf") == "LANG=de_DE.UTF-8" ]] || fail "Global leaves a language China did not set" -printf 'LANG=en_US.UTF-8\n' >"$root/etc/locale.conf" -pass "the region sets the language and Global only undoes Chinese" +[[ ! -s $calls && $(<"$root/etc/locale.conf") == "LANG=zh_CN.UTF-8" ]] || fail "Global keeps a Chinese language" +pass "Global leaves the language alone" [[ ! -e $root/etc/environment.d/90-omarchy-china.conf && ! -e $root/.cargo/config.toml && ! -e $root/etc/gemrc ]] || fail "Global removes the developer mirror drop-ins" pass "Global removes the developer mirror drop-ins"