slitaz-tools view tinyutils/tazlocale @ rev 170

tazlocale: dispaly locale name
author Christophe Lincoln <pankso@slitaz.org>
date Sun May 04 16:35:33 2008 +0200 (2008-05-04)
parents c26b3dc5e83f
children b444e2fc93fc
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=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 -e "\nYou must be root to run `basename $0`!"
27 echo -e "Type su and root password to become super-user.\n"
28 exit 1
29 fi
31 # Locale name displayed.
32 get_locale_name()
33 {
34 for i in `locale -a | grep "[a-z]_"`
35 do
36 name=`locale -a -v | grep -A 2 "locale: $i" | grep "title" | \
37 cut -d " " -f 7`
38 echo "$i $name"
39 done
40 }
42 # Dialog menu.
43 #
44 exec 3>&1
45 value=`$DIALOG --clear \
46 --title " SliTaz locale configuration " \
47 --menu \
48 "Select your language - Séléctionnez votre langue" 15 70 5 \
49 "en" "English" \
50 $(get_locale_name) \
51 2>&1 1>&3`
52 retval=$?
53 exec 3>&-
55 case $retval in
56 0)
57 continue ;;
58 1)
59 echo "Cancel pressed."
60 exit 0 ;;
61 255)
62 if test -n "$value"; then
63 echo "$value"
64 else
65 echo "ESC pressed."
66 exit 0
67 fi ;;
68 esac
70 # Default: C = English
71 if [ "$value" = "en" ]; then
72 value='C'
73 fi
75 # System configuration
76 echo "LANG=$value" > /etc/locale.conf
77 echo "LC_ALL=$value" >> /etc/locale.conf
79 . /etc/locale.conf
80 export LANG LC_ALL
82 exit 0