#!/bin/sh
#
#	$Id: lang.sh 9958 2008-11-04 18:07:58Z glen $
#

if [ -f /etc/sysconfig/i18n ]; then
	ORG_LANG=$LANG
	ORG_LC_ADDRESS=$LC_ADDRESS
	ORG_LC_COLLATE=$LC_COLLATE
	ORG_LC_CTYPE=$LC_CTYPE
	ORG_LC_IDENTIFICATION=$LC_IDENTIFICATION
	ORG_LC_MEASUREMENT=$LC_MEASUREMENT
	ORG_LC_MESSAGES=$LC_MESSAGES
	ORG_LC_MONETARY=$LC_MONETARY
	ORG_LC_NAME=$LC_NAME
	ORG_LC_NUMERIC=$LC_NUMERIC
	ORG_LC_PAPER=$LC_PAPER
	ORG_LC_TELEPHONE=$LC_TELEPHONE
	ORG_LC_TIME=$LC_TIME
	ORG_LC_ALL=$LC_ALL

	. /etc/sysconfig/i18n

	# we prefer session settings (that came from ssh for example)
	# instead of system one

	LANG=${ORG_LANG:-$LANG}
	LC_ADDRESS=${ORG_LC_ADDRESS:-$LC_ADDRESS}
	LC_COLLATE=${ORG_LC_COLLATE:-$LC_COLLATE}
	LC_CTYPE=${ORG_LC_CTYPE:-$LC_CTYPE}
	LC_IDENTIFICATION=${ORG_LC_IDENTIFICATION:-$LC_IDENTIFICATION}
	LC_MEASUREMENT=${ORG_LC_MEASUREMENT:-$LC_MEASUREMENT}
	LC_MESSAGES=${ORG_LC_MESSAGES:-$LC_MESSAGES}
	LC_MONETARY=${ORG_LC_MONETARY:-$LC_MONETARY}
	LC_NAME=${ORG_LC_NAME:-$LC_NAME}
	LC_NUMERIC=${ORG_LC_NUMERIC:-$LC_NUMERIC}
	LC_PAPER=${ORG_LC_PAPER:-$LC_PAPER}
	LC_TELEPHONE=${ORG_LC_TELEPHONE:-$LC_TELEPHONE}
	LC_TIME=${ORG_LC_TIME:-$LC_TIME}
	LC_ALL=${ORG_LC_ALL:-$LC_ALL}

	unset ORG_LANG ORG_LC_ADDRESS ORG_LC_COLLATE ORG_LC_CTYPE ORG_LC_IDENTIFICATION ORG_LC_MEASUREMENT
	unset ORG_LC_MESSAGES ORG_LC_MONETARY ORG_LC_NAME ORG_LC_NUMERIC ORG_LC_PAPER ORG_LC_TELEPHONE
	unset ORG_LC_TIME ORG_LC_ALL

	[ "$LANG" ] && export LANG || unset LANG
	[ "$LC_ADDRESS" ] && export LC_ADDRESS || unset LC_ADDRESS
	[ "$LC_COLLATE" ] && export LC_COLLATE || unset LC_COLLATE
	[ "$LC_CTYPE" ] && export LC_CTYPE || unset LC_CTYPE
	[ "$LC_IDENTIFICATION" ] && export LC_IDENTIFICATION || unset LC_IDENTIFICATION
	[ "$LC_MEASUREMENT" ] && export LC_MEASUREMENT || unset LC_MEASUREMENT
	[ "$LC_MESSAGES" ] && export LC_MESSAGES || unset LC_MESSAGES
	[ "$LC_MONETARY" ] && export LC_MONETARY || unset LC_MONETARY
	[ "$LC_NAME" ] && export LC_NAME || unset LC_NAME
	[ "$LC_NUMERIC" ] && export LC_NUMERIC || unset LC_NUMERIC
	[ "$LC_PAPER" ] && export LC_PAPER || unset LC_PAPER
	[ "$LC_TELEPHONE" ] && export LC_TELEPHONE || unset LC_TELEPHONE
	[ "$LC_TIME" ] && export LC_TIME || unset LC_TIME
	[ "$LC_ALL" ] && export LC_ALL || unset LC_ALL
	[ "$LANGUAGE" ] && export LANGUAGE || unset LANGUAGE
	[ "$LINGUAS" ] && export LINGUAS || unset LINGUAS

	[ "$_XKB_CHARSET" ] && export _XKB_CHARSET || unset _XKB_CHARSET

	if [ "$INPUTRC" ]; then
		export INPUTRC
	fi

	if [ "$LESSCHARSET" ]; then
		export LESSCHARSET
	elif [ "$TERM" = "linux-lat" ]; then
		LESSCHARSET=latin1
		export LESSCHARSET
	fi
fi
