[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#254452: Languages switches to english after rebooting during base-config



* Matt Kraai [2004-06-17 19:30:44-0700]
[previous patch]
> Should you also copy the code that handles LANGUAGE and
> LANGUAGE_INST?

In fact, due to its importance, we should make the locale setting code 
more evident.  Following patch resolves the code repetiveness problem 
and also ensures this requirement.  It needs a test though.  Could you 
review the patch?

-- 
roktas
--- termwrap.orig	2004-06-18 10:57:07.000000000 +0300
+++ termwrap	2004-06-18 11:56:13.000000000 +0300
@@ -47,6 +47,25 @@
 	echo "error: $@"
 }
 
+set_lang_language() {
+	# The locale should be validated before.
+
+	if [ "$1" ]; then
+		warning "Setting locale to '$1'."
+		LANG=$1
+		LC_ALL=$1
+		# Set the collating order as POSIX.
+		LC_COLLATE=C
+		export LANG LC_ALL LC_COLLATE
+	fi
+
+	if [ "$2" ]; then
+		warning "Setting language to '$2'."
+		LANGUAGE=$2
+		export LANGUAGE
+	fi
+}
+
 unset_lang_language() {
 	# The requested charset is not supported.  Do not use the
 	# given locale.	 If it was used, the translated texts might be
@@ -142,22 +161,14 @@
 
 		# Make sure the locale is valid
 		if validlocale $LANG_INST > /dev/null 2>&1 ; then
-			if [ "$LANGUAGE_INST" ]; then
-				LANGUAGE=$LANGUAGE_INST
-				export LANGUAGE
-				unset LANGUAGE_INST
-			fi
-			LANG=$LANG_INST
-			LC_ALL=$LANG_INST
-			LC_COLLATE=C
-			export LANG LC_ALL LC_COLLATE
-			unset LANG_INST
-		else
-			unset LANG_INST
-			unset LANGUAGE_INST
+			set_lang_language $LANG_INST $LANGUAGE_INST
 		fi
+	else
+		set_lang_language $LANG_INST $LANGUAGE_INST
 	fi
 
+	unset LANG_INST
+	unset LANGUAGE_INST
 	unset locale
 	unset charset
 	unset localeconf

Reply to: