flavors diff xfce/rootfs/sbin/tazlocale @ rev 130
Rename: core-xfce --> xfce
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Wed Feb 22 23:26:35 2012 +0100 (2012-02-22) |
parents | core-xfce/rootfs/sbin/tazlocale@d851f7b01f92 |
children |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/xfce/rootfs/sbin/tazlocale Wed Feb 22 23:26:35 2012 +0100 1.3 @@ -0,0 +1,137 @@ 1.4 +#!/bin/sh 1.5 +# 1.6 +# Tazlocale: SliTaz GNU/Linux locale setting using dialog boxes. 1.7 +# Configuration file is : /etc/locale.conf 1.8 +# 1.9 +# 20100201 <pankso@slitaz.org> - GNU gpl. 1.10 +# 1.11 + 1.12 +# Check if user is root. 1.13 +if test $(id -u) != 0; then 1.14 + echo -e "\nYou must be root to run `basename $0`!" 1.15 + echo -e "Type su and root password to become super-user.\n" 1.16 + exit 1 1.17 +fi 1.18 + 1.19 +get_messages() 1.20 +{ 1.21 + [ -f "/etc/locale.conf" ] && . /etc/locale.conf 1.22 + LANGUAGE=${LANG%_*} 1.23 + [ "$LANG" = "C" ] && LANGUAGE="en_US" 1.24 + case $LANGUAGE in 1.25 + fr*) 1.26 + RECONFIG_MSG=" 1.27 +Veuilliez fermer votre session et vous reloguer pour utiliser SliTaz \ 1.28 +avec la locale : $LANG" ;; 1.29 + *) 1.30 + RECONFIG_MSG=" 1.31 +Please logout of your current session and login again to use SliTaz \ 1.32 +with $LANG locale." ;; 1.33 + esac 1.34 +} 1.35 + 1.36 +# Create symlink to translated files provide by SliTaz language pack, 1.37 +# doc and config files. 1.38 +link_language_files() 1.39 +{ 1.40 + . /etc/locale.conf 1.41 + LANGUAGE=${LANG%_*} 1.42 + [ "$LANG" = "C" ] && LANGUAGE="en" 1.43 + # Openbox menu in /usr/share/doc/slitaz 1.44 + if [ -f /etc/xdg/openbox/menu.$LANGUAGE.xml ]; then 1.45 + cd /etc/xdg/openbox && rm -f menu.xml 1.46 + ln -s menu.$LANGUAGE.xml menu.xml 1.47 + fi 1.48 + # Documentation in /usr/share/doc/slitaz 1.49 + if [ -f /usr/share/doc/slitaz/index.$LANGUAGE.html ]; then 1.50 + cd /usr/share/doc/slitaz && rm -f index.html 1.51 + ln -s index.$LANGUAGE.html index.html 1.52 + fi 1.53 + # SliTaz Software Manuals 1.54 + for soft in tazpkg tazlito tazusb tazwok 1.55 + do 1.56 + if [ -f /usr/share/doc/$soft/$soft.$LANGUAGE.html ]; then 1.57 + cd /usr/share/doc/$soft && rm -f $soft.html 1.58 + ln -s $soft.$LANGUAGE.html $soft.html 1.59 + fi 1.60 + done 1.61 +} 1.62 + 1.63 +# Locale name displayed. 1.64 +get_locale_name() 1.65 +{ 1.66 + for i in `ls -1 /usr/share/i18n/locales/ | grep ^[a-z][a-z]_[A-Z][A-Z]` 1.67 + do 1.68 + #name=`locale -a -v | grep -A 2 "locale: $i" | grep "title" | \ 1.69 + # cut -d " " -f 7` 1.70 + echo "$i Locale" 1.71 + done 1.72 +} 1.73 + 1.74 +# We have no locale files in /usr/lib/locale by default. Run localedef in 1.75 +# background to have a faster boot. 1.76 +gen_utf8_locale() 1.77 +{ 1.78 + localedef -i $locale -c -f UTF-8 /usr/lib/locale/$locale & 1.79 +} 1.80 + 1.81 +# Dialog menu. 1.82 +dialog_menu() 1.83 +{ 1.84 + exec 3>&1 1.85 + locale=`$DIALOG --clear \ 1.86 + --title " SliTaz language configuration " \ 1.87 + --menu "" 15 70 5 \ 1.88 +"en" "English" \ 1.89 +$(get_locale_name) \ 1.90 +2>&1 1>&3` 1.91 + retval=$? 1.92 + exec 3>&- 1.93 + case $retval in 1.94 + 0) 1.95 + continue ;; 1.96 + 1) 1.97 + echo "Cancel pressed." 1.98 + exit 0 ;; 1.99 + 255) 1.100 + if test -n "$locale"; then 1.101 + echo "$locale" 1.102 + else 1.103 + echo "ESC pressed." 1.104 + exit 0 1.105 + fi ;; 1.106 + esac 1.107 + # Default: C = English 1.108 + [ "$locale" = "en" ] && locale="en_US" 1.109 + [ -s /etc/locale.conf ] && RECONFIG="yes" 1.110 + # System configuration 1.111 + echo "LANG=$locale" > /etc/locale.conf 1.112 + echo "LC_ALL=$locale" >> /etc/locale.conf 1.113 + export LANG=$locale LC_ALL=$locale 1.114 + gen_utf8_locale 1.115 + get_messages 1.116 + # If it's a reconfiguration give an info message. 1.117 + if [ -n "$RECONFIG" ]; then 1.118 + $DIALOG --clear \ 1.119 + --title " Information " \ 1.120 + --msgbox "$RECONFIG_MSG" 16 70 1.121 + fi 1.122 +} 1.123 + 1.124 +case "$1" in 1.125 + *_*) 1.126 + # Execute functions (can be called from an other apps). 1.127 + $1 ;; 1.128 + link-files) 1.129 + link_language_files ;; 1.130 + list) 1.131 + echo "" 1.132 + locale -a 1.133 + echo "" ;; 1.134 + *) 1.135 + : ${DIALOG=dialog} 1.136 + dialog_menu 1.137 + link_language_files ;; 1.138 +esac 1.139 + 1.140 +exit 0