Files
omarchy/install/config/region.sh
T
ZacharyZhang-NY fdd457c0fa Merge #14433 input methods and remove Rime
The keyboard choice and omarchy-setup-input own Chinese input now. The
new passwordless sudo and input tooltips get Chinese text.
2026-10-08 23:30:41 -04:00

53 lines
1.4 KiB
Bash

cn_links=(
"environment.conf /etc/environment.d/90-omarchy-china.conf"
"cargo.toml /.cargo/config.toml"
"gemrc /etc/gemrc"
)
# The installer writes the marker; omarchy-region passes the region it switches to.
region=global
if [[ -e /etc/omarchy/region ]]; then
region=$(</etc/omarchy/region)
fi
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
rm "$target"
fi
done
;;
cn)
for link in "${cn_links[@]}"; do
read -r _ target <<<"$link"
if [[ -e $target && ! -L $target ]]; then
echo "Refusing to replace $target, which Omarchy did not create" >&2
exit 1
fi
done
mkdir -p /etc/omarchy
echo cn >/etc/omarchy/region
for link in "${cn_links[@]}"; do
read -r source target <<<"$link"
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
exit 1
;;
esac