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:
ZacharyZhang-NY committed 2026-10-08 23:44:04 -04:00
1 parent 1824bc3066
commit 199a7f23fc
13 files changed
+157 -46

No files matched your search

+1
View File
@@ -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"
+42
View File
@@ -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
+3 -10
View File
@@ -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