From 79215ca29e587fe46b194db39c97a445e291ce38 Mon Sep 17 00:00:00 2001 From: Akad <134841282+Hexalantes@users.noreply.github.com> Date: Tue, 1 Sep 2026 09:57:42 +0300 Subject: [PATCH] Enhance locale setup with additional variables Add locale variables for GUI applications and improve error handling. --- sysding | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/sysding b/sysding index ce7ba35..bff9004 100644 --- a/sysding +++ b/sysding @@ -336,21 +336,35 @@ setup_locale() { # set up zones default locale typeset def_locale typeset rt - + typeset lc_base + typeset lc_lang + typeset lc_language def_locale="$1" rt=0 - if ! locale -a | egrep "^${def_locale}$$" 2>&1 >/dev/null ; then + if ! locale -a | egrep "^${def_locale}\$" >/dev/null 2>&1 ; then # selected locale is not installed - fall back to C and log error - log_error "specified locale ${def_locale} not installed, reverting to C" - def_local="C" - rt=42 - fi - + log_error "specified locale ${def_locale} not installed, reverting to C" + def_locale="C" + rt=42 + fi printf ",g,^LANG=,d\na\nLANG=%s\n.\nw\nq\n" "${def_locale}" | ed /etc/default/init - REBOOT_NEEDED=yes + # set locale variables for gui apps if it's not fallback + if [ "${def_locale}" != "C" ]; then + lc_base="${def_locale%%.*}" + lc_lang="${lc_base%%_*}" + if [ "${lc_lang}" = "en" ]; then + lc_language="${lc_base}:en" + else + lc_language="${lc_base}:${lc_lang}:en" + fi + + printf "export LANG=%s\nexport LC_TIME=\$LANG\nexport LC_MESSAGES=\$LANG\nexport LANGUAGE=%s\n" \ + "${def_locale}" "${lc_language}" >> /etc/profile + fi + REBOOT_NEEDED=yes return ${rt} }