slitaz-tools view tinyutils/tazlocale @ rev 296

desktopbox: Add autostart (GUI to enable/disable apps started with Openbox)
author Christophe Lincoln <pankso@slitaz.org>
date Sat Feb 21 22:33:58 2009 +0100 (2009-02-21)
parents df6285a99463
children af65458ca488
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 # 20080417 <pankso@slitaz.org> - GNU gpl.
7 #
8 : ${DIALOG=tazdialog}
9 export ICON="preferences-desktop-locale"
11 # Script functions.
12 status()
13 {
14 local CHECK=$?
15 echo -en "\\033[70G[ "
16 if [ $CHECK = 0 ]; then
17 echo -en "\\033[1;33mOK"
18 else
19 echo -en "\\033[1;31mFailed"
20 fi
21 echo -e "\\033[0;39m ]"
22 }
24 # Check if user is root.
25 #
26 if test $(id -u) != 0; then
27 echo -e "\nYou must be root to run `basename $0`!"
28 echo -e "Type su and root password to become super-user.\n"
29 exit 1
30 fi
32 # Locale name displayed.
33 get_locale_name()
34 {
35 for i in `locale -a | grep "[a-z]_"`
36 do
37 name=`locale -a -v | grep -A 2 "locale: $i" | grep "title" | \
38 cut -d " " -f 7`
39 echo "$i $name"
40 done
41 }
43 # Dialog menu.
44 #
45 exec 3>&1
46 value=`$DIALOG --clear \
47 --title " SliTaz locale configuration " \
48 --menu \
49 "\nSelect your language - Séléctionnez votre langue" 15 70 5 \
50 "en" "English" \
51 $(get_locale_name) \
52 2>&1 1>&3`
53 retval=$?
54 exec 3>&-
56 case $retval in
57 0)
58 continue ;;
59 1)
60 echo "Cancel pressed."
61 exit 0 ;;
62 255)
63 if test -n "$value"; then
64 echo "$value"
65 else
66 echo "ESC pressed."
67 exit 0
68 fi ;;
69 esac
71 # Default: C = English
72 if [ "$value" = "en" ]; then
73 value='C'
74 fi
76 # If it's a reconfiguration give an info message.
77 if [ -s /etc/locale.conf ]; then
78 $DIALOG --clear \
79 --title " Locale setting information " \
80 --msgbox "\n
81 Please logout of your current session and login again to use $value
82 locale.\n" 16 70
83 fi
85 # System configuration
86 echo "LANG=$value" > /etc/locale.conf
87 echo "LC_ALL=$value" >> /etc/locale.conf
89 . /etc/locale.conf
90 export LANG LC_ALL
92 exit 0