From 137a7347ff975e4988d7fd999a0a6c32fee0464b Mon Sep 17 00:00:00 2001 From: Tom Gundersen Date: Mon, 17 Oct 2011 20:55:38 +0200 Subject: locale.sh: support /etc/locale.conf This is mainly to support non-bash shells that cannot source rc.conf. The format of /etc/locale.conf is described here: . If LANG is not set in locale.conf, then we fall back to LOCALE from rc.conf, as before. Signed-off-by: Tom Gundersen --- functions | 8 ++++++-- locale.sh | 11 +++++++++-- rc.conf | 1 + 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/functions b/functions index 2ea81f9..68f4229 100644 --- a/functions +++ b/functions @@ -67,8 +67,12 @@ unset TZ unset LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY \ LC_MESSAGES LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE \ LC_MEASUREMENT LC_IDENTIFICATION LC_ALL -if [[ $DAEMON_LOCALE = [yY][eE][sS] && $LOCALE ]]; then - export LANG="${LOCALE}" +if [[ $DAEMON_LOCALE = [yY][eE][sS] ]]; then + if [ -r /etc/locale.conf ]; then + . /etc/locale.conf + else + export LANG="${LOCALE}" + fi else export LANG=C fi diff --git a/locale.sh b/locale.sh index 6723f95..e774659 100644 --- a/locale.sh +++ b/locale.sh @@ -1,3 +1,10 @@ -. /etc/rc.conf +if [ -s /etc/rc.conf ]; then + LANG=$(. /etc/rc.conf 2> /dev/null ; echo "${LOCALE:=en_US.UTF-8}") +fi +if [ -s /etc/locale.conf ]; then + . /etc/locale.conf +fi -export LANG=${LOCALE:=en_US.UTF-8} +export LANG LANGUAGE LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE +export LC_MONETARY LC_MESSAGES LC_PAPER LC_NAME LC_ADDRESS +export LC_TELEPHONE LC_MEASUREMENT LC_IDENTIFICATION diff --git a/rc.conf b/rc.conf index 303a035..d91dff7 100644 --- a/rc.conf +++ b/rc.conf @@ -7,6 +7,7 @@ # ----------------------------------------------------------------------- # # LOCALE: available languages can be listed with the 'locale -a' command +# LANG in /etc/locale.conf takes precedence # DAEMON_LOCALE: If set to 'yes', use $LOCALE as the locale during daemon # startup and during the boot process. If set to 'no', the C locale is used. # HARDWARECLOCK: set to "", "UTC" or "localtime", any other value will result -- cgit v1.2.3