slitaz-tools rev 145

tazlocale: most rewrited and gen locale list automaticaly
author Christophe Lincoln <pankso@slitaz.org>
date Thu Apr 17 19:06:33 2008 +0200 (2008-04-17)
parents e36407c1b1dd
children 9e9f25d6d0cd
files tinyutils/tazlocale
line diff
     1.1 --- a/tinyutils/tazlocale	Wed Apr 16 20:38:25 2008 +0000
     1.2 +++ b/tinyutils/tazlocale	Thu Apr 17 19:06:33 2008 +0200
     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 -# 2007/11/04 <pankso@slitaz.org> - GNU gpl.
     1.8 +# 20080417 <pankso@slitaz.org> - GNU gpl.
     1.9  #
    1.10  : ${DIALOG=dialog}
    1.11  
    1.12 @@ -23,66 +23,66 @@
    1.13  # Check if user is root.
    1.14  #
    1.15  if test $(id -u) != 0; then
    1.16 -  echo ""
    1.17 -  echo "You must be root to run `basename $0`!"
    1.18 -  echo "Type su and root password to become super-user."
    1.19 -  echo ""
    1.20 -  exit 1
    1.21 +	echo -e "\nYou must be root to run `basename $0`!"
    1.22 +	echo -e "Type su and root password to become super-user.\n"
    1.23 +	exit 1
    1.24  fi
    1.25  
    1.26  # Dialog menu.
    1.27  #
    1.28  exec 3>&1
    1.29  value=`$DIALOG  --clear \
    1.30 -    --title " SliTaz locale configuration " \
    1.31 -    --menu \
    1.32 -"Séléctionnez votre langue - Select your language." 15 70 5 \
    1.33 -"fr_CH" "Français Suisse." \
    1.34 -"fr_FR" "Français France." \
    1.35 -"en" "English (POSIX)." \
    1.36 +	--title " SliTaz locale configuration " \
    1.37 +	--menu \
    1.38 +"Select your language - Séléctionnez votre langue" 15 70 5 \
    1.39 +$(cd /usr/share/i18n/locales/; ls -1 [a-z][a-z]_* | awk '{ printf "%s Locale\n",$1,$2 }') \
    1.40  2>&1 1>&3`
    1.41  retval=$?
    1.42  exec 3>&-
    1.43  
    1.44  case $retval in
    1.45 -  0)
    1.46 -    echo -n "$value selected... " 
    1.47 -    status ;;
    1.48 -  1)
    1.49 -    echo "Cancel pressed."
    1.50 -    exit 0 ;;
    1.51 -  255)
    1.52 -    if test -n "$value"; then
    1.53 -      echo "$value"
    1.54 -    else
    1.55 -      echo "ESC pressed."
    1.56 -      exit 0
    1.57 -    fi ;;
    1.58 +	0)
    1.59 +		continue ;;
    1.60 +	1)
    1.61 +		echo "Cancel pressed."
    1.62 +		exit 0 ;;
    1.63 +	255)
    1.64 +	if test -n "$value"; then
    1.65 +		echo "$value"
    1.66 +	else
    1.67 +		echo "ESC pressed."
    1.68 +		exit 0
    1.69 +	fi ;;
    1.70  esac
    1.71  
    1.72 -# Now we can creat /etc/locale.conf.
    1.73 +LOCALE=$value
    1.74 +
    1.75 +# Set charmaps, used files are in: /usr/share/i18n/charmaps
    1.76  #
    1.77 -case $value in
    1.78 -  fr_CH)
    1.79 -    echo "Paramétrage de la langue pour le français Suisse..."
    1.80 -    echo -n "Création du fichier de configuration : /etc/locale.conf"
    1.81 -    echo "LANG=fr_CH" > /etc/locale.conf
    1.82 -    echo "LC_ALL=fr_CH" >> /etc/locale.conf
    1.83 -    status ;;
    1.84 -  fr_FR)
    1.85 -    echo "Paramétrage de la langue pour le français France..."
    1.86 -    echo -n "Création du fichier de configuration : /etc/locale.conf"
    1.87 -    echo "LANG=fr_FR" > /etc/locale.conf
    1.88 -    echo "LC_ALL=fr_FR" >> /etc/locale.conf
    1.89 -    status ;;
    1.90 -  en)
    1.91 -    echo "Setting language to English (POSIX)... "
    1.92 -    echo -n "Creating configuration file : /etc/locale.conf"
    1.93 -    echo "LANG=POSIX" > /etc/locale.conf
    1.94 -    echo "LC_ALL=POSIX" >> /etc/locale.conf
    1.95 -    status ;;
    1.96 +case $LOCALE in
    1.97 +	# ISO-8859-1
    1.98 +	de_*|en_*|es_*|fr_*|it_IT)
    1.99 +		CHARMAP='ISO-8859-1' ;;
   1.100 +	# ISO-8859-2
   1.101 +	cs_*)
   1.102 +		CHARMAP='ISO-8859-2' ;;
   1.103 +	ru_*)
   1.104 +		CHARMAP='KOI8-RU' ;;
   1.105 + 	*)
   1.106 +		echo "Locale: $value specifications not yet implemeted... Sorry."
   1.107 +		CHARMAP='ISO-8859-1'
   1.108 +		LOCALE='en_US' ;;
   1.109  esac
   1.110  
   1.111 +# System configuration
   1.112 +echo -n "Setting system locale to: $value "
   1.113 +localedef -i $LOCALE -c -f ISO-8859-1 $fs/usr/lib/locale/$LOCALE
   1.114 +status
   1.115 +echo -n "Creating configuration file: /etc/locale.conf"
   1.116 +echo "LANG=$LOCALE" > /etc/locale.conf
   1.117 +echo "LC_ALL=$LOCALE" >> /etc/locale.conf
   1.118 +status
   1.119 +
   1.120  if [ -f "/etc/locale.conf" ]; then
   1.121  	. /etc/locale.conf
   1.122  	export LANG LC_ALL