slitaz-tools view tinyutils/tazlocale @ rev 37

Rewrite tazx and add more screen size and colors choice
author Christophe Lincoln <pankso@slitaz.org>
date Mon Jan 14 13:25:50 2008 +0100 (2008-01-14)
parents
children 6fdcd51993b5
line source
1 #!/bin/sh
2 #
3 # Tazlocale: SliTaz GNU/Linux locale setting using dialog boxes.
4 # Configuration file is : /etc/locale.conf
5 #
6 # 2007/11/04 <pankso@slitaz.org> - GNU gpl.
7 #
8 : ${DIALOG=dialog}
10 # Script functions.
11 status()
12 {
13 local CHECK=$?
14 echo -en "\\033[70G[ "
15 if [ $CHECK = 0 ]; then
16 echo -en "\\033[1;33mOK"
17 else
18 echo -en "\\033[1;31mFailed"
19 fi
20 echo -e "\\033[0;39m ]"
21 }
23 # Check if user is root.
24 #
25 if test $(id -u) != 0; then
26 echo ""
27 echo "You must be root to run `basename $0`!"
28 echo "Type su and root password to become super-user."
29 echo ""
30 exit 1
31 fi
33 # Dialog menu.
34 #
35 exec 3>&1
36 value=`$DIALOG --clear \
37 --title " SliTaz locale configuration " \
38 --menu \
39 "Séléctionnez votre langue - Select your language." 15 70 5 \
40 "fr_CH" "Français Suisse." \
41 "fr_FR" "Français France." \
42 "en" "English (POSIX)." \
43 2>&1 1>&3`
44 retval=$?
45 exec 3>&-
47 case $retval in
48 0)
49 echo -n "$value selected... "
50 status ;;
51 1)
52 echo "Cancel pressed."
53 exit 0 ;;
54 255)
55 if test -n "$value"; then
56 echo "$value"
57 else
58 echo "ESC pressed."
59 exit 0
60 fi ;;
61 esac
63 # Now we can creat /etc/locale.conf.
64 #
65 case $value in
66 fr_CH)
67 echo "Paramétrage de la langue pour le français Suisse..."
68 echo -n "Création du fichier de configuration : /etc/locale.conf"
69 echo "LANG=fr_CH" > /etc/locale.conf
70 echo "LC_ALL=fr_CH" >> /etc/locale.conf
71 status ;;
72 fr_FR)
73 echo "Paramétrage de la langue pour le français France..."
74 echo -n "Création du fichier de configuration : /etc/locale.conf"
75 echo "LANG=fr_FR" > /etc/locale.conf
76 echo "LC_ALL=fr_FR" >> /etc/locale.conf
77 status ;;
78 en)
79 echo "Setting language to English (POSIX)... "
80 echo -n "Creating configuration file : /etc/locale.conf"
81 echo "LANG=POSIX" > /etc/locale.conf
82 echo "LC_ALL=POSIX" >> /etc/locale.conf
83 status ;;
84 esac
86 if [ -f "/etc/locale.conf" ]; then
87 . /etc/locale.conf
88 export LANG LC_ALL
89 fi
91 exit 0