#!/bin/bash
# omarchy:summary=Generate zh_CN.UTF-8 and en_US.UTF-8 locales
# omarchy:examples=omarchycn locale apply
# omarchy:requires-sudo=true

set -euo pipefail

for loc in "zh_CN.UTF-8 UTF-8" "en_US.UTF-8 UTF-8"; do
  if ! grep -qE "^${loc% *}" /etc/locale.gen; then
    echo "$loc" | sudo tee -a /etc/locale.gen > /dev/null
  fi
done

sudo locale-gen
echo "Locales available: $(locale -a | grep -cE 'zh_CN|en_US') (zh_CN/en_US variants)"
