slitaz-tools diff tinyutils/tazlocale @ rev 549

Tiny edits
author Paul Issott <paul@slitaz.org>
date Sun Mar 06 19:58:55 2011 +0000 (2011-03-06)
parents adf1e99ee3e8
children 513cf2248bf4
line diff
     1.1 --- a/tinyutils/tazlocale	Tue May 12 23:05:47 2009 +0000
     1.2 +++ b/tinyutils/tazlocale	Sun Mar 06 19:58:55 2011 +0000
     1.3 @@ -3,7 +3,7 @@
     1.4  # Tazlocale: SliTaz GNU/Linux locale setting using dialog boxes.
     1.5  # Configuration file is : /etc/locale.conf
     1.6  #
     1.7 -# 20090428 <pankso@slitaz.org> - GNU gpl.
     1.8 +# 20100201 <pankso@slitaz.org> - GNU gpl.
     1.9  #
    1.10  
    1.11  # Check if user is root.
    1.12 @@ -15,16 +15,18 @@
    1.13  
    1.14  get_messages()
    1.15  {
    1.16 -	. /etc/locale.conf
    1.17 +	[ -f "/etc/locale.conf" ] && . /etc/locale.conf
    1.18  	LANGUAGE=${LANG%_*}
    1.19 -	[ "$LANG" = "C" ] && LANGUAGE="en"
    1.20 +	[ "$LANG" = "C" ] && LANGUAGE="en_US"
    1.21  	case $LANGUAGE in
    1.22 -		fr)
    1.23 -			RECONFIG_MSG="Veuilliez fermer votre session et vous 
    1.24 -			reloguer pour utiliser SliTaz avec la locale : fr." ;;
    1.25 +		fr*)
    1.26 +			RECONFIG_MSG="
    1.27 +Veuilliez fermer votre session et vous reloguer pour utiliser SliTaz \
    1.28 +avec la locale : $LANG" ;;
    1.29  		*)
    1.30 -			RECONFIG_MSG="Please logout of your current session and 
    1.31 -			login again to use SliTaz with $LANGUAGE locale." ;;
    1.32 +			RECONFIG_MSG="
    1.33 +Please logout of your current session and login again to use SliTaz \
    1.34 +with $LANG locale." ;;
    1.35  	esac
    1.36  }
    1.37  
    1.38 @@ -58,19 +60,26 @@
    1.39  # Locale name displayed.
    1.40  get_locale_name()
    1.41  {
    1.42 -	for i in `locale -a | grep "[a-z]_"`
    1.43 +	for i in `ls -1 /usr/share/i18n/locales/ | grep ^[a-z][a-z]_[A-Z][A-Z]`
    1.44  	do
    1.45 -		name=`locale -a -v | grep -A 2 "locale: $i" | grep "title" | \
    1.46 -			cut -d " " -f 7`
    1.47 -		echo "$i $name"
    1.48 +		#name=`locale -a -v | grep -A 2 "locale: $i" | grep "title" | \
    1.49 +		#	cut -d " " -f 7`
    1.50 +		echo "$i Locale"
    1.51  	done
    1.52  }
    1.53  
    1.54 +# We have no locale files in /usr/lib/locale by default. Run localedef in
    1.55 +# background to have a faster boot.
    1.56 +gen_utf8_locale()
    1.57 +{
    1.58 +	localedef -i $locale -c -f UTF-8 /usr/lib/locale/$locale &
    1.59 +}
    1.60 +
    1.61  # Dialog menu.
    1.62  dialog_menu()
    1.63  {
    1.64  	exec 3>&1
    1.65 -	value=`$DIALOG  --clear \
    1.66 +	locale=`$DIALOG  --clear \
    1.67  	--title " SliTaz language configuration " \
    1.68  	--menu "" 15 70 5 \
    1.69  "en" "English" \
    1.70 @@ -85,20 +94,21 @@
    1.71  			echo "Cancel pressed."
    1.72  			exit 0 ;;
    1.73  		255)
    1.74 -			if test -n "$value"; then
    1.75 -				echo "$value"
    1.76 +			if test -n "$locale"; then
    1.77 +				echo "$locale"
    1.78  			else
    1.79  				echo "ESC pressed."
    1.80  				exit 0
    1.81  			fi ;;
    1.82  	esac
    1.83  	# Default: C = English
    1.84 -	[ "$value" = "en" ] && value="C"
    1.85 +	[ "$locale" = "en" ] && locale="en_US"
    1.86  	[ -s /etc/locale.conf ] && RECONFIG="yes"
    1.87  	# System configuration
    1.88 -	echo "LANG=$value" > /etc/locale.conf
    1.89 -	echo "LC_ALL=$value" >> /etc/locale.conf
    1.90 -	export LANG=$value LC_ALL=$value
    1.91 +	echo "LANG=$locale" > /etc/locale.conf
    1.92 +	echo "LC_ALL=$locale" >> /etc/locale.conf
    1.93 +	export LANG=$locale LC_ALL=$locale
    1.94 +	gen_utf8_locale
    1.95  	get_messages
    1.96  	# If it's a reconfiguration give an info message.
    1.97  	if [ -n "$RECONFIG" ]; then
    1.98 @@ -114,17 +124,12 @@
    1.99  		$1 ;;
   1.100  	link-files)
   1.101  		link_language_files ;;
   1.102 -	dialog)
   1.103 -		: ${DIALOG=dialog}
   1.104 -		dialog_menu
   1.105 -		link_language_files ;;
   1.106  	list)
   1.107  		echo ""
   1.108  		locale -a
   1.109  		echo "" ;;
   1.110  	*)
   1.111 -		: ${DIALOG=tazdialog}
   1.112 -		export ICON="preferences-desktop-locale"
   1.113 +		: ${DIALOG=dialog}
   1.114  		dialog_menu
   1.115  		link_language_files ;;
   1.116  esac