diff options
author | Jo-Philipp Wich <jow@openwrt.org> | 2011-12-20 00:08:07 +0000 |
---|---|---|
committer | Jo-Philipp Wich <jow@openwrt.org> | 2011-12-20 00:08:07 +0000 |
commit | 5de0c58bd9da282de31934a2fe3b12240d5238a2 (patch) | |
tree | da5f563e793c8d01bff63c40355f2aafc44655fd /applications/luci-firewall/luasrc/model | |
parent | 50380b9fb6eb971a6d5fc7cca4e06c0102b1d3d1 (diff) |
applications/luci-firewall: make rule descriptions fully translateable
Diffstat (limited to 'applications/luci-firewall/luasrc/model')
-rw-r--r-- | applications/luci-firewall/luasrc/model/cbi/firewall/forwards.lua | 47 | ||||
-rw-r--r-- | applications/luci-firewall/luasrc/model/cbi/firewall/rules.lua | 101 |
2 files changed, 65 insertions, 83 deletions
diff --git a/applications/luci-firewall/luasrc/model/cbi/firewall/forwards.lua b/applications/luci-firewall/luasrc/model/cbi/firewall/forwards.lua index 3ab3658e9e..b07aa90417 100644 --- a/applications/luci-firewall/luasrc/model/cbi/firewall/forwards.lua +++ b/applications/luci-firewall/luasrc/model/cbi/firewall/forwards.lua @@ -62,7 +62,7 @@ function s.parse(self, ...) if created then m.uci:save("firewall") luci.http.redirect(ds.build_url( - "admin", "network", "firewall", "redirect", created + "admin/network/firewall/redirect", created )) end end @@ -87,55 +87,48 @@ src = s:option(DummyValue, "src", translate("Source")) src.rawhtml = true src.width = "20%" function src.cfgvalue(self, s) - local z = ft.fmt_zone(self.map:get(s, "src")) - local a = ft.fmt_ip(self.map:get(s, "src_ip")) + local z = ft.fmt_zone(self.map:get(s, "src"), translate("any zone")) + local a = ft.fmt_ip(self.map:get(s, "src_ip"), translate("any host")) local p = ft.fmt_port(self.map:get(s, "src_port")) local m = ft.fmt_mac(self.map:get(s, "src_mac")) - local s = "From %s in %s " %{ - (a or "<var>any host</var>"), - (z or "<var>any zone</var>") - } - if p and m then - s = s .. "with source %s and %s" %{ p, m } + return translatef("From %s in %s with source %s and %s", a, z, p, m) elseif p or m then - s = s .. "with source %s" %( p or m ) + return translatef("From %s in %s with source %s", a, z, p or m) + else + return translatef("From %s in %s", a, z) end - - return s end via = s:option(DummyValue, "via", translate("Via")) via.rawhtml = true via.width = "20%" function via.cfgvalue(self, s) - local a = ft.fmt_ip(self.map:get(s, "src_dip")) + local a = ft.fmt_ip(self.map:get(s, "src_dip"), translate("any router IP")) local p = ft.fmt_port(self.map:get(s, "src_dport")) - --local z = self.map:get(s, "src") - --local s = "To %s " %(a or "<var>any %s IP</var>" %( z or "router" )) - - return "To %s%s" %{ - (a or "<var>any router IP</var>"), - (p and " at %s" % p or "") - } + if p then + return translatef("To %s at %s", a, p) + else + return translatef("To %s", a) + end end dest = s:option(DummyValue, "dest", translate("Destination")) dest.rawhtml = true dest.width = "30%" function dest.cfgvalue(self, s) - local z = ft.fmt_zone(self.map:get(s, "dest")) - local a = ft.fmt_ip(self.map:get(s, "dest_ip")) + local z = ft.fmt_zone(self.map:get(s, "dest"), translate("any zone")) + local a = ft.fmt_ip(self.map:get(s, "dest_ip"), translate("any host")) local p = ft.fmt_port(self.map:get(s, "dest_port")) or ft.fmt_port(self.map:get(s, "src_dport")) - return "Forward to %s%s in %s " %{ - (a or "<var>any host</var>"), - (p and ", %s" % p or ""), - (z or "<var>any zone</var>") - } + if p then + return translatef("Forward to %s, %s in %s", a, p, z) + else + return translatef("Forward to %s in %s", a, z) + end end return m diff --git a/applications/luci-firewall/luasrc/model/cbi/firewall/rules.lua b/applications/luci-firewall/luasrc/model/cbi/firewall/rules.lua index 05e98a9db7..f76380c79b 100644 --- a/applications/luci-firewall/luasrc/model/cbi/firewall/rules.lua +++ b/applications/luci-firewall/luasrc/model/cbi/firewall/rules.lua @@ -77,7 +77,7 @@ function s.parse(self, ...) if created then m.uci:save("firewall") luci.http.redirect(ds.build_url( - "admin", "network", "firewall", "rules", created + "admin/network/firewall/rules", created )) end end @@ -111,23 +111,18 @@ src = s:option(DummyValue, "src", translate("Source")) src.rawhtml = true src.width = "20%" function src.cfgvalue(self, s) - local z = ft.fmt_zone(self.map:get(s, "src")) - local a = ft.fmt_ip(self.map:get(s, "src_ip")) + local z = ft.fmt_zone(self.map:get(s, "src"), translate("any zone")) + local a = ft.fmt_ip(self.map:get(s, "src_ip"), translate("any host")) local p = ft.fmt_port(self.map:get(s, "src_port")) local m = ft.fmt_mac(self.map:get(s, "src_mac")) - local s = "From %s in %s " %{ - (a or "<var>any host</var>"), - (z or "<var>any zone</var>") - } - if p and m then - s = s .. "with source %s and %s" %{ p, m } + return translatef("From %s in %s with source %s and %s", a, z, p, m) elseif p or m then - s = s .. "with source %s" %( p or m ) + return translatef("From %s in %s with source %s", a, z, p or m) + else + return translatef("From %s in %s", a, z) end - - return s end dest = s:option(DummyValue, "dest", translate("Destination")) @@ -135,23 +130,27 @@ dest.rawhtml = true dest.width = "20%" function dest.cfgvalue(self, s) local z = ft.fmt_zone(self.map:get(s, "dest")) - local a = ft.fmt_ip(self.map:get(s, "dest_ip")) local p = ft.fmt_port(self.map:get(s, "dest_port")) -- Forward if z then - return "To %s%s in %s" %{ - (a or "<var>any host</var>"), - (p and ", %s" % p or ""), - z - } + local a = ft.fmt_ip(self.map:get(s, "dest_ip"), translate("any host")) + if p then + return translatef("To %s, %s in %s", a, p, z) + else + return translatef("To %s in %s", a, z) + end -- Input else - return "To %s%s on <var>this device</var>" %{ - (a or "<var>any router IP</var>"), - (p and " at %s" % p or "") - } + local a = ft.fmt_ip(self.map:get(s, "dest_ip"), + translate("any router IP")) + + if p then + return translatef("To %s at %s on <var>this device</var>", a, p) + else + return translatef("To %s on <var>this device</var>", a) + end end end @@ -160,15 +159,15 @@ target = s:option(DummyValue, "target", translate("Action")) target.rawhtml = true target.width = "20%" function target.cfgvalue(self, s) - local z = ft.fmt_zone(self.map:get(s, "dest")) - local l = ft.fmt_limit(self.map:get(s, "limit"), self.map:get(s, "limit_burst")) - local t = ft.fmt_target(self.map:get(s, "target")) - - return "<var>%s</var> %s%s" %{ - t, - (z and "forward" or "input"), - (l and " and limit to %s" % l or "") - } + local t = ft.fmt_target(self.map:get(s, "target"), self.map:get(s, "dest")) + local l = ft.fmt_limit(self.map:get(s, "limit"), + self.map:get(s, "limit_burst")) + + if l then + return translatef("<var>%s</var> and limit to %s", t, l) + else + return "<var>%s</var>" % t + end end @@ -242,39 +241,34 @@ src = s:option(DummyValue, "src", translate("Source")) src.rawhtml = true src.width = "20%" function src.cfgvalue(self, s) - local z = ft.fmt_zone(self.map:get(s, "src")) - local a = ft.fmt_ip(self.map:get(s, "src_ip")) + local z = ft.fmt_zone(self.map:get(s, "src"), translate("any zone")) + local a = ft.fmt_ip(self.map:get(s, "src_ip"), translate("any host")) local p = ft.fmt_port(self.map:get(s, "src_port")) local m = ft.fmt_mac(self.map:get(s, "src_mac")) - local s = "From %s in %s " %{ - (a or "<var>any host</var>"), - (z or "<var>any zone</var>") - } - if p and m then - s = s .. "with source %s and %s" %{ p, m } + return translatef("From %s in %s with source %s and %s", a, z, p, m) elseif p or m then - s = s .. "with source %s" %( p or m ) + return translatef("From %s in %s with source %s", a, z, p or m) + else + return translatef("From %s in %s", a, z) end - - return s end dest = s:option(DummyValue, "dest", translate("Destination")) dest.rawhtml = true dest.width = "30%" function dest.cfgvalue(self, s) - local z = ft.fmt_zone(self.map:get(s, "dest")) - local a = ft.fmt_ip(self.map:get(s, "dest_ip")) + local z = ft.fmt_zone(self.map:get(s, "dest"), translate("any zone")) + local a = ft.fmt_ip(self.map:get(s, "dest_ip"), translate("any host")) local p = ft.fmt_port(self.map:get(s, "dest_port")) or ft.fmt_port(self.map:get(s, "src_dport")) - return "To %s%s in %s " %{ - (a or "<var>any host</var>"), - (p and ", %s" % p or ""), - (z or "<var>any zone</var>") - } + if p then + return translatef("To %s, %s in %s", a, p, z) + else + return translatef("To %s in %s", a, z) + end end snat = s:option(DummyValue, "via", translate("SNAT")) @@ -284,15 +278,10 @@ function snat.cfgvalue(self, s) local a = ft.fmt_ip(self.map:get(s, "src_dip")) local p = ft.fmt_port(self.map:get(s, "src_dport")) - --local z = self.map:get(s, "src") - --local s = "To %s " %(a or "<var>any %s IP</var>" %( z or "router" )) - if a and p then - return "Rewrite to source %s, %s" %{ a, p } - elseif a or p then - return "Rewrite to source %s" %( a or p ) + return translatef("Rewrite to source %s, %s", a, p) else - return "Bug" + return translatef("Rewrite to source %s", a or p) end end |