slitaz-tools rev 749
tazlocale: update and use libtaz.sh
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Mon Apr 30 12:00:30 2012 +0200 (2012-04-30) |
parents | 090f11a4dab5 |
children | d73b013e8885 |
files | tinyutils/tazlocale |
line diff
1.1 --- a/tinyutils/tazlocale Mon Apr 30 10:45:16 2012 +0200 1.2 +++ b/tinyutils/tazlocale Mon Apr 30 12:00:30 2012 +0200 1.3 @@ -3,21 +3,18 @@ 1.4 # Tazlocale: SliTaz GNU/Linux locale setting using dialog boxes. 1.5 # Configuration file is : /etc/locale.conf 1.6 # 1.7 -# 20110614 <pankso@slitaz.org> - GNU gpl. 1.8 +# Copyright (C) 2008-2012 SliTaz GNU/Linux - BSD License 1.9 # 1.10 +# Author: Christophe Lincoln <pankso@slitaz.org> 1.11 +# 1.12 +. /lib/libtaz.sh 1.13 +check_root 1.14 1.15 # Internationalization 1.16 . /usr/bin/gettext.sh 1.17 TEXTDOMAIN='slitaz-tools' 1.18 export TEXTDOMAIN 1.19 1.20 -# Check if user is root. 1.21 -if test $(id -u) != 0; then 1.22 - gettext "You must be root to run:"; echo " $(basename $0)" 1.23 - gettext "Type su and root password to become super-user"; echo 1.24 - exit 1 1.25 -fi 1.26 - 1.27 # Create symlink to translated files provided by SliTaz language pack, 1.28 # doc and config files. 1.29 link_language_files() 1.30 @@ -54,10 +51,10 @@ 1.31 ln -s index.$LANGUAGE.html index.html 1.32 fi 1.33 # SliTaz Tools Manuals 1.34 - for soft in burnbox tazinst 1.35 + for soft in tazinst 1.36 do 1.37 - if [ -f /usr/share/doc/slitaz-tools/$soft.$LANGUAGE.html ]; then 1.38 - cd /usr/share/doc/slitaz-tools && rm -f $soft.html 1.39 + if [ -f /usr/share/doc/slitaz/$soft.$LANGUAGE.html ]; then 1.40 + cd /usr/share/doc/slitaz && rm -f $soft.html 1.41 ln -s $soft.$LANGUAGE.html $soft.html 1.42 fi 1.43 done 1.44 @@ -66,7 +63,7 @@ 1.45 # Locale name displayed. 1.46 get_locale_name() 1.47 { 1.48 - for i in `ls -1 /usr/share/i18n/locales | grep ^[a-z][a-z]_[A-Z][A-Z]` 1.49 + for i in $(ls -1 /usr/share/i18n/locales | grep ^[a-z][a-z]_[A-Z][A-Z]) 1.50 do 1.51 #desc=$(grep ^title /usr/share/i18n/locales/$i | cut -d '"' -f 2) 1.52 echo "$i Locale" 1.53 @@ -80,16 +77,27 @@ 1.54 localedef -i $locale -c -f UTF-8 /usr/lib/locale/$locale & 1.55 } 1.56 1.57 +# Config /etc/locale.conf 1.58 +system_config() { 1.59 + export LANG=$locale LC_ALL=$locale 1.60 + gettext "Configuring system locale for:"; echo -n " $locale" 1.61 + echo "LANG=$locale" > /etc/locale.conf 1.62 + echo "LC_ALL=$locale" >> /etc/locale.conf 1.63 + status 1.64 + gen_utf8_locale 1.65 + link_language_files 1.66 +} 1.67 + 1.68 # Dialog menu. 1.69 dialog_menu() 1.70 { 1.71 exec 3>&1 1.72 - locale=`$DIALOG --clear \ 1.73 + locale=$($DIALOG --clear \ 1.74 --title " $(gettext "SliTaz language configuration") " \ 1.75 --menu "" 15 70 5 \ 1.76 "en" "English" \ 1.77 $(get_locale_name) \ 1.78 -2>&1 1>&3` 1.79 +2>&1 1>&3) 1.80 retval=$? 1.81 exec 3>&- 1.82 case $retval in 1.83 @@ -101,13 +109,6 @@ 1.84 [ "$locale" = "en" ] && locale="en_US" 1.85 [ -s /etc/locale.conf ] && RECONFIG="yes" 1.86 1.87 - # System configuration 1.88 - echo "LANG=$locale" > /etc/locale.conf 1.89 - echo "LC_ALL=$locale" >> /etc/locale.conf 1.90 - export LANG=$locale LC_ALL=$locale 1.91 - gen_utf8_locale 1.92 - link_language_files 1.93 - 1.94 # If it's a reconfiguration give an info message. 1.95 if [ -n "$RECONFIG" ]; then 1.96 msg=$(gettext "\ 1.97 @@ -116,27 +117,26 @@ 1.98 --title " Information " \ 1.99 --msgbox "$msg" 16 70 1.100 fi 1.101 + system_config 1.102 } 1.103 1.104 case "$1" in 1.105 - *_*) 1.106 - # Execute functions (can be called from an other apps). 1.107 - $1 ;; 1.108 list) 1.109 - echo "" 1.110 - locale -a 1.111 - echo "" ;; 1.112 - init) 1.113 - # This command can be used to change system locale from cmdline. 1.114 - locale=$2 1.115 - echo "LANG=$locale" > /etc/locale.conf 1.116 - echo "LC_ALL=$locale" >> /etc/locale.conf 1.117 + for i in $(ls -1 /usr/share/i18n/locales | grep ^[a-z][a-z]_[A-Z][A-Z]) 1.118 + do 1.119 + desc=$(grep ^title /usr/share/i18n/locales/$i | cut -d '"' -f 2) 1.120 + echo "$i $desc" 1.121 + done ;; 1.122 + "") 1.123 + # No args: display Ncurses dialog. 1.124 + : ${DIALOG=dialog} 1.125 + dialog_menu ;; 1.126 + *) 1.127 + # Usage: tazlocale LANG_COUNTRY 1.128 + locale=$1 1.129 + system_config 1.130 gen_utf8_locale 1.131 link_language_files ;; 1.132 - *) 1.133 - : ${DIALOG=dialog} 1.134 - dialog_menu 1.135 - link_language_files ;; 1.136 esac 1.137 1.138 exit 0