Fix: Erase all forgotten stuff from grml-config-user [Closes: issue1272]
[grml-scripts.git] / usr_sbin / grml-setlang
index f8cb28b..ae6a096 100755 (executable)
@@ -4,7 +4,6 @@
 # Authors:       grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
 # Bug-Reports:   see http://grml.org/bugs/
 # License:       This file is licensed under the GPL v2.
-# Latest change: Mit Sep 05 18:33:23 CEST 2007 [mika]
 ################################################################################
 
 PN="$(basename $0)"
@@ -166,29 +165,36 @@ if ! grep -qe "${LANGUAGE})" -qe "${LANGUAGE}|" $LANGFUNC ; then
    ewarn "Language ${LANGUAGE} not supported, using default." ; eend 0
 fi
 
+# fallback to C if using an ISO system (which is latin1 for LC_CTYPE);
+# this should prevent users from broken ctype settings if the set
+# locale isn't available on a remote system
+if echo $LANGUAGE | grep -q -- '-iso' ; then
+   LC_CTYPE=C
+fi
+
 # read in the file where all the $LANGUAGE stuff is defined
-  source $LANGFUNC
+  . $LANGFUNC
 
 # make sure the file exists
 if ! [ -r $CONFFILE ] ; then
 cat > $CONFFILE <<EOF
 # File generated by $PN on $(date)
-LANGUAGE=$LANGUAGE
 LANG=$LANG
-LC_MESSAGES=$LANG
+# LC_CTYPE=$LC_CTYPE
+# LANGUAGE=$LANGUAGE
 # TZ=$TZ
 # other environment variables you might want to set:
-# LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY
-# LC_MESSAGES LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE
-# LC_MEASUREMENT LC_IDENTIFICATION
-# Notice: set LC_ALL to overwrite all LC_* variables
+# LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY
+# LC_MESSAGES LC_PAPER LC_NAME LC_ADDRESS
+# LC_TELEPHONE LC_MEASUREMENT LC_IDENTIFICATION
+#
+# Note: set LC_ALL to overwrite all LC_* variables
+#       LC_ALL > LC_* > LANG
+#       LANGUAGE is glibc only and binds stronger than LC_ALL
 EOF
 fi
 
-setvalue 'LANGUAGE='    $LANGUAGE
-setvalue 'LANG='        $LANG
-setvalue 'LC_MESSAGES=' $LANG
-# setvalue 'TZ='          $TZ
+setvalue 'LANG='     $LANG
 
 retval=$?
 case $retval in