flavors view core/rootfs/sbin/tazlocale @ rev 15

Keep 4 flavors + loram + 3in1 and add tmp addfiles for core
author Christophe Lincoln <pankso@slitaz.org>
date Tue Feb 02 22:26:52 2010 +0100 (2010-02-02)
parents
children
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 # 20100201 <pankso@slitaz.org> - GNU gpl.
7 #
9 # Check if user is root.
10 if test $(id -u) != 0; then
11 echo -e "\nYou must be root to run `basename $0`!"
12 echo -e "Type su and root password to become super-user.\n"
13 exit 1
14 fi
16 get_messages()
17 {
18 [ -f "/etc/locale.conf" ] && . /etc/locale.conf
19 LANGUAGE=${LANG%_*}
20 [ "$LANG" = "C" ] && LANGUAGE="en_US"
21 case $LANGUAGE in
22 fr*)
23 RECONFIG_MSG="
24 Veuilliez fermer votre session et vous reloguer pour utiliser SliTaz \
25 avec la locale : $LANG" ;;
26 *)
27 RECONFIG_MSG="
28 Please logout of your current session and login again to use SliTaz \
29 with $LANG locale." ;;
30 esac
31 }
33 # Create symlink to translated files provide by SliTaz language pack,
34 # doc and config files.
35 link_language_files()
36 {
37 . /etc/locale.conf
38 LANGUAGE=${LANG%_*}
39 [ "$LANG" = "C" ] && LANGUAGE="en"
40 # Openbox menu in /usr/share/doc/slitaz
41 if [ -f /etc/xdg/openbox/menu.$LANGUAGE.xml ]; then
42 cd /etc/xdg/openbox && rm -f menu.xml
43 ln -s menu.$LANGUAGE.xml menu.xml
44 fi
45 # Documentation in /usr/share/doc/slitaz
46 if [ -f /usr/share/doc/slitaz/index.$LANGUAGE.html ]; then
47 cd /usr/share/doc/slitaz && rm -f index.html
48 ln -s index.$LANGUAGE.html index.html
49 fi
50 # SliTaz Software Manuals
51 for soft in tazpkg tazlito tazusb tazwok
52 do
53 if [ -f /usr/share/doc/$soft/$soft.$LANGUAGE.html ]; then
54 cd /usr/share/doc/$soft && rm -f $soft.html
55 ln -s $soft.$LANGUAGE.html $soft.html
56 fi
57 done
58 }
60 # Locale name displayed.
61 get_locale_name()
62 {
63 for i in `ls -1 /usr/share/i18n/locales/ | grep ^[a-z][a-z]_[A-Z][A-Z]`
64 do
65 #name=`locale -a -v | grep -A 2 "locale: $i" | grep "title" | \
66 # cut -d " " -f 7`
67 echo "$i Locale"
68 done
69 }
71 # We have no locale files in /usr/lib/locale by default. Run localedef in
72 # background to have a faster boot.
73 gen_utf8_locale()
74 {
75 localedef -i $locale -c -f UTF-8 /usr/lib/locale/$locale &
76 }
78 # Dialog menu.
79 dialog_menu()
80 {
81 exec 3>&1
82 locale=`$DIALOG --clear \
83 --title " SliTaz language configuration " \
84 --menu "" 15 70 5 \
85 "en" "English" \
86 $(get_locale_name) \
87 2>&1 1>&3`
88 retval=$?
89 exec 3>&-
90 case $retval in
91 0)
92 continue ;;
93 1)
94 echo "Cancel pressed."
95 exit 0 ;;
96 255)
97 if test -n "$locale"; then
98 echo "$locale"
99 else
100 echo "ESC pressed."
101 exit 0
102 fi ;;
103 esac
104 # Default: C = English
105 [ "$locale" = "en" ] && locale="en_US"
106 [ -s /etc/locale.conf ] && RECONFIG="yes"
107 # System configuration
108 echo "LANG=$locale" > /etc/locale.conf
109 echo "LC_ALL=$locale" >> /etc/locale.conf
110 export LANG=$locale LC_ALL=$locale
111 gen_utf8_locale
112 get_messages
113 # If it's a reconfiguration give an info message.
114 if [ -n "$RECONFIG" ]; then
115 $DIALOG --clear \
116 --title " Information " \
117 --msgbox "$RECONFIG_MSG" 16 70
118 fi
119 }
121 case "$1" in
122 *_*)
123 # Execute functions (can be called from an other apps).
124 $1 ;;
125 link-files)
126 link_language_files ;;
127 list)
128 echo ""
129 locale -a
130 echo "" ;;
131 *)
132 : ${DIALOG=dialog}
133 dialog_menu
134 link_language_files ;;
135 esac
137 exit 0