slitaz-tools diff tinyutils/tazlocale @ rev 961

tazlocale: accept only existing locales, show locale description; translations: un-fuzzy already translated messages
author Aleksej Bobylev <al.bobylev@gmail.com>
date Wed Nov 25 23:50:30 2015 +0200 (2015-11-25)
parents 3be081525506
children bb7be0ca546f
line diff
     1.1 --- a/tinyutils/tazlocale	Thu Jun 04 17:11:36 2015 +0300
     1.2 +++ b/tinyutils/tazlocale	Wed Nov 25 23:50:30 2015 +0200
     1.3 @@ -91,8 +91,13 @@
     1.4  
     1.5  get_locale_name() {
     1.6  	for i in $(ls -1 /usr/share/i18n/locales | grep [a-z]_[A-Z]); do
     1.7 -		#desc=$(grep ^title /usr/share/i18n/locales/$i | cut -d '"' -f 2)
     1.8 -		echo "$i Locale"
     1.9 +		echo -n "$i "
    1.10 +		desc=$(grep ^title /usr/share/i18n/locales/$i | cut -d '"' -f 2)
    1.11 +		if [ -n "$desc" ]; then
    1.12 +			echo "$desc" | tr -c '[A-Za-z0-9\n]' '_'
    1.13 +		else
    1.14 +			echo "Locale"
    1.15 +		fi
    1.16  	done
    1.17  }
    1.18  
    1.19 @@ -101,20 +106,25 @@
    1.20  # Run localedef in background to have a faster boot.
    1.21  
    1.22  gen_utf8_locale() {
    1.23 -	[ -e /usr/lib/locale/$locale ] || \
    1.24 -		localedef -i $locale -c -f UTF-8 /usr/lib/locale/$locale &
    1.25 +	if [ ! -d "/usr/lib/locale/$locale.UTF-8" ]; then
    1.26 +		localedef -i "$locale" -c -f 'UTF-8' "/usr/lib/locale/$locale.UTF-8" &
    1.27 +	fi
    1.28  }
    1.29  
    1.30  
    1.31  # Config /etc/locale.conf
    1.32  
    1.33  system_config() {
    1.34 -	export LC_ALL=$locale
    1.35 -	_n 'Setting system locale to: %s' "$locale"
    1.36 -	echo -e "LANG=$locale\nLC_ALL=$locale" > /etc/locale.conf
    1.37 +	# If locale not defined: show error and exit
    1.38 +	ls "/usr/share/i18n/locales/$locale" >/dev/null || return
    1.39 +	export LC_ALL="$locale.UTF-8"
    1.40 +	action 'Setting system locale to: %s' "$locale.UTF-8"
    1.41 +	echo -e "LANG=$locale.UTF-8\nLC_ALL=$locale.UTF-8" > /etc/locale.conf
    1.42  	status
    1.43  	gen_utf8_locale
    1.44  	link_language_files
    1.45 +	# Clean TazPanel cached headers in old language
    1.46 +	[ -n "$(which tazpanel)" ] && tazpanel cc
    1.47  }
    1.48  
    1.49  
    1.50 @@ -153,6 +163,7 @@
    1.51  	--help|-h)
    1.52  		usage ;;
    1.53  	info)
    1.54 +		. /etc/locale.conf
    1.55  		_ 'Config file: %s' '/etc/locale.conf'
    1.56  		_ 'Current locale: %s' "$LANG"
    1.57  		;;