add webif language changer to system settings
authorFelix Fietkau <nbd@openwrt.org>
Mon, 6 Feb 2006 02:37:42 +0000 (02:37 +0000)
committerFelix Fietkau <nbd@openwrt.org>
Mon, 6 Feb 2006 02:37:42 +0000 (02:37 +0000)
SVN-Revision: 3157

openwrt/package/webif/files/usr/lib/webif/lang/de/common.txt
openwrt/package/webif/files/usr/lib/webif/lang/fr/common.txt
openwrt/package/webif/files/usr/lib/webif/languages.awk [new file with mode: 0644]
openwrt/package/webif/files/www/cgi-bin/webif/system.sh

index f4f62ba9c181b5ea0c2146199cf8ad4fba57838b..2b21f165ada94207535b2ee5b9baf6a8e2b39ffd 100644 (file)
@@ -1,3 +1,4 @@
+lang => Deutsch
 # Common
 Settings saved => Einstellungen gespeichert
 Settings not saved => Einstellungen nicht gespeichert
index 376c1a00ce3c2542c39bda7b857fdb30ad870165..8e4d56e386f6ac1df1a6494220385000ac9ea9fd 100644 (file)
@@ -1,3 +1,4 @@
+#lang => Fran&ccedil;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 (file)
index 0000000..f0111dd
--- /dev/null
@@ -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
+}
index a169a3b480fdfbccd62695171eec67eb7a2e9d25..51bda647080729d9f4a92e7a991b066fbd732682 100755 (executable)
@@ -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<<System Settings>>" '' "$SCRIPT_NAME"
 
 is_bcm947xx && bootwait_form="field|boot_wait
@@ -38,7 +44,9 @@ start_form|@TR<<System Settings>>
 field|@TR<<Host Name>>
 text|hostname|$FORM_hostname
 $bootwait_form
-field
+field|Language
+select|language|$FORM_language
+$LANGUAGES
 end_form
 EOF