tazpanel rev 313

new locale chooser
author Aleksej Bobylev <al.bobylev@gmail.com>
date Thu May 17 15:03:15 2012 +0300 (2012-05-17)
parents 42367a53cf50
children 03de38e7cdf3
files settings.cgi
line diff
     1.1 --- a/settings.cgi	Thu May 17 14:52:15 2012 +0300
     1.2 +++ b/settings.cgi	Thu May 17 15:03:15 2012 +0300
     1.3 @@ -175,6 +175,72 @@
     1.4  </section>
     1.5  EOT
     1.6  		;;
     1.7 +
     1.8 +
     1.9 +	*\ locale*)
    1.10 +		#
    1.11 +		# Choose locale
    1.12 +		#
    1.13 +		LOADING_MSG="$(gettext 'Please wait...')"
    1.14 +		loading_msg
    1.15 +		cur_loc=$(locale | grep LANG | cut -d= -f2)
    1.16 +		cat <<EOT
    1.17 +<h3 id="locale">$(gettext 'Choose locale')</h3>
    1.18 +
    1.19 +<p>$(gettext 'Current locale settings:')</p>
    1.20 +<pre>$(locale)</pre>
    1.21 +
    1.22 +<p>$(gettext 'Locales that are currently installed on the machine:')</p>
    1.23 +<pre>$(locale -a)</pre>
    1.24 +
    1.25 +<p>$(gettext 'Available locales:')</p>
    1.26 +
    1.27 +<form method="get" action="$SCRIPT_NAME">
    1.28 +	<div class="outbox">
    1.29 +	<table class="zebra fixed">
    1.30 +	<thead>
    1.31 +		<tr><td style="width:9em">$(gettext 'Code')</td>
    1.32 +			<td style="width:10em">$(gettext 'Language')</td>
    1.33 +			<td style="width:10em">$(gettext 'Territory')</td>
    1.34 +			<td>$(gettext 'Description')</td>
    1.35 +		</tr>
    1.36 +	</thead>
    1.37 +	</table>
    1.38 +
    1.39 +	<div style="max-height: 16em; overflow:auto">
    1.40 +	<table class="zebra fixed">
    1.41 +		<col style="width:9em">
    1.42 +		<col style="width:10em">
    1.43 +		<col style="width:10em">
    1.44 +		<col>
    1.45 +	<tbody style="max-height:10em; overflow:auto">
    1.46 +EOT
    1.47 +	for locale in $(find /usr/share/i18n/locales -type f | sort)
    1.48 +	do
    1.49 +		locale_name=$(basename $locale)
    1.50 +		locale_title=$(grep -m 1 -e '^	*title' $locale | cut -d'"' -f2)
    1.51 +		if [ -n "$locale_title" ]; then
    1.52 +			sel=""; [ "$locale_name" == "$cur_loc" ] && sel="checked"
    1.53 +			cat << EOT
    1.54 +		<tr><td><input type="radio" name="gen_locale" value="$locale_name" $sel />$locale_name</td>
    1.55 +			<td>$(gettext -d iso_639 "$(grep -m 1 -e '^	*language' $locale | cut -d '"' -f2)")</td>
    1.56 +			<td>$(gettext -d iso_3166 "$(grep -m 1 -e '^	*territory' $locale | cut -d '"' -f2)")</td>
    1.57 +			<td>$locale_title</td>
    1.58 +		</tr>
    1.59 +EOT
    1.60 +		fi
    1.61 +	done
    1.62 +	cat << EOT
    1.63 +	</tbody>
    1.64 +	</table>
    1.65 +	</div>
    1.66 +	</div>
    1.67 +	<p><input type="submit" value="$(gettext 'Activate')" /></p>
    1.68 +</form>
    1.69 +EOT
    1.70 +		;;
    1.71 +
    1.72 +
    1.73  	*)
    1.74  		#
    1.75  		# Defaut system settings page
    1.76 @@ -193,7 +259,8 @@
    1.77  <h3>$(gettext 'System time')</h3>
    1.78  
    1.79  <table>
    1.80 -	<tr><td>$(gettext 'Time zome:')</td><td>$(cat /etc/TZ)</td></tr>
    1.81 +	<tr><td>$(gettext 'Time zome:')</td><td>$(cat /etc/TZ)
    1.82 +		<a class="button" href="$SCRIPT_NAME">$(gettext 'Change')</a></td></tr>
    1.83  	<tr><td>$(gettext 'System time:')</td><td>$(date)</td></tr>
    1.84  	<tr><td>$(gettext 'Hardware clock:')</td><td>$(hwclock -r)</tr>
    1.85  </table>
    1.86 @@ -220,19 +287,11 @@
    1.87  			eval_gettext "You must logout and login again to your current \
    1.88  session to use \$new_locale locale."
    1.89  		else
    1.90 -			gettext 'Current system locales:'
    1.91 -			locale -a
    1.92 +			gettext 'Current system locale:'; echo -n " <strong>"
    1.93 +			locale | grep LANG | cut -d= -f2
    1.94  		fi
    1.95  		cat << EOT
    1.96 -</p>
    1.97 -<form method="get" action="$SCRIPT_NAME">
    1.98 -	$(gettext 'Available locales:')
    1.99 -	<select name="gen_locale">
   1.100 -		<option value="en_US">en__US</options>
   1.101 -		$(list_locales)
   1.102 -	</select>
   1.103 -	<input type="submit" value="$(gettext 'Activate')" />
   1.104 -</form>
   1.105 +</strong> <a class="button" href="$SCRIPT_NAME?locale">$(gettext 'Change')</a></p>
   1.106  </section>
   1.107  
   1.108  <section>