slitaz-tools view tinyutils/tazlocale @ rev 777

tazlocale: remove burnbox doc reference (it was moved to oldstuff after 4.0 release)
author Claudinei Pereira <claudinei@slitaz.org>
date Sun Sep 02 13:42:48 2012 -0300 (2012-09-02)
parents 8c8b2c646040
children e232f0e1413a
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 # Copyright (C) 2008-2012 SliTaz GNU/Linux - BSD License
7 #
8 # Author: Christophe Lincoln <pankso@slitaz.org>
9 #
10 . /lib/libtaz.sh
12 # Internationalization
13 . /usr/bin/gettext.sh
14 TEXTDOMAIN='slitaz-tools'
15 export TEXTDOMAIN
17 # Create symlink to translated files provided by SliTaz language pack,
18 # doc and config files.
19 link_language_files()
20 {
21 . /etc/locale.conf
22 LANGUAGE=${LANG%_*}
23 [ "$LANG" = "POSIX" ] && LANGUAGE="en"
24 # Openbox menu in /usr/share/doc/slitaz
25 if [ -f /etc/xdg/openbox/menu.$LANGUAGE.xml ]; then
26 cd /etc/xdg/openbox && rm -f menu.xml
27 ln -s menu.$LANGUAGE.xml menu.xml
28 fi
29 # Documentation in /usr/share/doc/slitaz
30 if [ -f /usr/share/doc/slitaz/index.$LANGUAGE.html ]; then
31 cd /usr/share/doc/slitaz && rm -f index.html
32 ln -s index.$LANGUAGE.html index.html
33 fi
34 # SliTaz Software Manuals
35 for soft in tazpkg tazlito tazusb tazwok tazweb cookutils
36 do
37 if [ -f /usr/share/doc/$soft/$soft.$LANGUAGE.html ]; then
38 cd /usr/share/doc/$soft && rm -f $soft.html
39 ln -s $soft.$LANGUAGE.html $soft.html
40 fi
41 done
42 # SliTaz TazWeb "My Web Home"
43 if [ -f /usr/share/tazweb/home.$LANGUAGE.html ]; then
44 cd /usr/share/tazweb && rm -f home.html
45 ln -s home.$LANGUAGE.html home.html
46 fi
47 # SliTaz WebHome
48 if [ -f /usr/share/webhome/index.$LANGUAGE.html ]; then
49 cd /usr/share/webhome && rm -f index.html
50 ln -s index.$LANGUAGE.html index.html
51 fi
52 # TazPanel Doc under www
53 if [ -f /var/www/tazpanel/doc/tazpanel.$LANGUAGE.html ]; then
54 cd /var/www/tazpanel/doc && rm -f tazpanel.html
55 ln -s tazpanel.$LANGUAGE.html tazpanel.html
56 fi
57 # SliTaz Tools Manuals
58 for soft in tazinst
59 do
60 if [ -f /usr/share/doc/slitaz/$soft.$LANGUAGE.html ]; then
61 cd /usr/share/doc/slitaz && rm -f $soft.html
62 ln -s $soft.$LANGUAGE.html $soft.html
63 fi
64 done
65 }
67 # Locale name displayed.
68 get_locale_name()
69 {
70 for i in $(ls -1 /usr/share/i18n/locales | grep ^[a-z][a-z]_[A-Z][A-Z])
71 do
72 #desc=$(grep ^title /usr/share/i18n/locales/$i | cut -d '"' -f 2)
73 echo "$i Locale"
74 done
75 }
77 # We have no locale files in /usr/lib/locale by default. Run localedef in
78 # background to have a faster boot.
79 gen_utf8_locale()
80 {
81 localedef -i $locale -c -f UTF-8 /usr/lib/locale/$locale &
82 }
84 # Config /etc/locale.conf
85 system_config() {
86 export LC_ALL=$locale
87 gettext "Setting system locale to:"; echo -n " $locale"
88 echo "LANG=$locale" > /etc/locale.conf
89 echo "LC_ALL=$locale" >> /etc/locale.conf
90 # Resource libtaz.sh to get status message in the correct locale.
91 . /lib/libtaz.sh && status
92 gen_utf8_locale
93 link_language_files
94 }
96 # Dialog menu.
97 dialog_menu()
98 {
99 exec 3>&1
100 locale=$($DIALOG --clear \
101 --title " $(gettext "SliTaz language configuration") " \
102 --menu "" 15 70 5 \
103 "en" "English" \
104 $(get_locale_name) \
105 2>&1 1>&3)
106 retval=$?
107 exec 3>&-
108 case $retval in
109 0) continue ;;
110 1|255) exit 0 ;;
111 esac
113 # Default: POSIX = English
114 [ "$locale" = "en" ] && locale="en_US"
115 [ -s /etc/locale.conf ] && RECONFIG="yes"
117 # If it's a reconfiguration give an info message.
118 if [ -n "$RECONFIG" ]; then
119 export LC_ALL=$locale
120 msg=$(gettext "\
121 Please logout of your current session and login again to use new locale.")
122 $DIALOG --clear --title " Information " --msgbox "$msg" 16 70
123 fi
124 system_config
125 }
127 case "$1" in
128 info)
129 gettext "Config file :"; echo " /etc/locale.conf"
130 gettext "Current locale:"; echo " $LANG" ;;
131 list)
132 for i in $(ls -1 /usr/share/i18n/locales | grep ^[a-z][a-z]_[A-Z][A-Z])
133 do
134 desc=$(grep ^title /usr/share/i18n/locales/$i | cut -d '"' -f 2)
135 echo "$i $desc"
136 done ;;
137 "")
138 # No args: display Ncurses dialog.
139 : ${DIALOG=dialog}
140 check_root
141 dialog_menu ;;
142 *)
143 # Usage: tazlocale LANG_COUNTRY
144 locale=$1
145 check_root
146 system_config
147 gen_utf8_locale
148 link_language_files ;;
149 esac
151 exit 0