From d31e6395c1b2828d3a84423b2cf355773231ca94 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Mon, 6 Feb 2006 02:37:42 +0000 Subject: [PATCH] add webif language changer to system settings SVN-Revision: 3157 --- .../files/usr/lib/webif/lang/de/common.txt | 1 + .../files/usr/lib/webif/lang/fr/common.txt | 1 + .../webif/files/usr/lib/webif/languages.awk | 12 ++++++++++ .../webif/files/www/cgi-bin/webif/system.sh | 22 +++++++++++++------ 4 files changed, 29 insertions(+), 7 deletions(-) create mode 100644 openwrt/package/webif/files/usr/lib/webif/languages.awk diff --git a/openwrt/package/webif/files/usr/lib/webif/lang/de/common.txt b/openwrt/package/webif/files/usr/lib/webif/lang/de/common.txt index f4f62ba9c1..2b21f165ad 100644 --- a/openwrt/package/webif/files/usr/lib/webif/lang/de/common.txt +++ b/openwrt/package/webif/files/usr/lib/webif/lang/de/common.txt @@ -1,3 +1,4 @@ +lang => Deutsch # Common Settings saved => Einstellungen gespeichert Settings not saved => Einstellungen nicht gespeichert diff --git a/openwrt/package/webif/files/usr/lib/webif/lang/fr/common.txt b/openwrt/package/webif/files/usr/lib/webif/lang/fr/common.txt index 376c1a00ce..8e4d56e386 100644 --- a/openwrt/package/webif/files/usr/lib/webif/lang/fr/common.txt +++ b/openwrt/package/webif/files/usr/lib/webif/lang/fr/common.txt @@ -1,3 +1,4 @@ +#lang => Français Encoding => UTF-8 # Common diff --git a/openwrt/package/webif/files/usr/lib/webif/languages.awk b/openwrt/package/webif/files/usr/lib/webif/languages.awk new file mode 100644 index 0000000000..f0111dd26f --- /dev/null +++ b/openwrt/package/webif/files/usr/lib/webif/languages.awk @@ -0,0 +1,12 @@ +BEGIN { + print "option|en|English" +} + +/webif\/lang\/[a-zA-Z][a-zA-Z]*/ { + gsub(/^.*webif\/lang\//, "") + shortname = $0 + gsub(/\/.*$/, "", shortname) + gsub(/^.*=>[ \t]*/, "") + longname = $0 + print "option|" shortname "|" longname +} diff --git a/openwrt/package/webif/files/www/cgi-bin/webif/system.sh b/openwrt/package/webif/files/www/cgi-bin/webif/system.sh index a169a3b480..51bda64708 100755 --- a/openwrt/package/webif/files/www/cgi-bin/webif/system.sh +++ b/openwrt/package/webif/files/www/cgi-bin/webif/system.sh @@ -3,13 +3,16 @@ . /usr/lib/webif/webif.sh load_settings system load_settings nvram +load_settings webif if empty "$FORM_submit"; then - FORM_hostname=${wan_hostname:-$(nvram get wan_hostname)} - FORM_hostname=${FORM_hostname:-OpenWrt} + FORM_hostname="${wan_hostname:-$(nvram get wan_hostname)}" + FORM_hostname="${FORM_hostname:-OpenWrt}" + FORM_language="${language:-$(nvram get language)}" + FORM_language="${FORM_language:-default}" is_bcm947xx && { - FORM_boot_wait=${boot_wait:-$(nvram get boot_wait)} - FORM_boot_wait=${FORM_boot_wait:-off} + FORM_boot_wait="${boot_wait:-$(nvram get boot_wait)}" + FORM_boot_wait="${FORM_boot_wait:-off}" } else SAVED=1 @@ -17,15 +20,18 @@ else hostname|FORM_hostname|Hostname|nodots required|$FORM_hostname EOF equal "$?" 0 && { - save_setting system wan_hostname $FORM_hostname + save_setting system wan_hostname "$FORM_hostname" + save_setting webif language "$FORM_language" is_bcm947xx && { case "$FORM_boot_wait" in - on|off) save_setting nvram boot_wait $FORM_boot_wait;; + on|off) save_setting nvram boot_wait "$FORM_boot_wait";; esac } } fi +LANGUAGES="$(grep '^[\t ]*lang[\t ]*=>' /usr/lib/webif/lang/*/*.txt | awk -f /usr/lib/webif/languages.awk)" + header "System" "Settings" "@TR<>" '' "$SCRIPT_NAME" is_bcm947xx && bootwait_form="field|boot_wait @@ -38,7 +44,9 @@ start_form|@TR<> field|@TR<> text|hostname|$FORM_hostname $bootwait_form -field +field|Language +select|language|$FORM_language +$LANGUAGES end_form EOF -- 2.30.2