luci-app-firewall: rename tr() helper function to _()
Rename tr() to _() so that i18n-scan.pl picks up the language strings. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
This commit is contained in:
parent
5248587ebe
commit
e79a0ded7f
1 changed files with 29 additions and 29 deletions
|
@ -9,7 +9,7 @@ local nx = require "nixio"
|
||||||
|
|
||||||
local translate, translatef = luci.i18n.translate, luci.i18n.translatef
|
local translate, translatef = luci.i18n.translate, luci.i18n.translatef
|
||||||
|
|
||||||
local function tr(...)
|
local function _(...)
|
||||||
return tostring(translate(...))
|
return tostring(translate(...))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ function fmt_neg(x)
|
||||||
if type(x) == "string" then
|
if type(x) == "string" then
|
||||||
local v, neg = x:gsub("^ *! *", "")
|
local v, neg = x:gsub("^ *! *", "")
|
||||||
if neg > 0 then
|
if neg > 0 then
|
||||||
return v, "%s " % tr("not")
|
return v, "%s " % _("not")
|
||||||
else
|
else
|
||||||
return x, ""
|
return x, ""
|
||||||
end
|
end
|
||||||
|
@ -28,7 +28,7 @@ end
|
||||||
function fmt_mac(x)
|
function fmt_mac(x)
|
||||||
if x and #x > 0 then
|
if x and #x > 0 then
|
||||||
local m, n
|
local m, n
|
||||||
local l = { tr("MAC"), " " }
|
local l = { _("MAC"), " " }
|
||||||
for m in ut.imatch(x) do
|
for m in ut.imatch(x) do
|
||||||
m, n = fmt_neg(m)
|
m, n = fmt_neg(m)
|
||||||
l[#l+1] = "<var>%s%s</var>" %{ n, m }
|
l[#l+1] = "<var>%s%s</var>" %{ n, m }
|
||||||
|
@ -37,7 +37,7 @@ function fmt_mac(x)
|
||||||
if #l > 1 then
|
if #l > 1 then
|
||||||
l[#l] = nil
|
l[#l] = nil
|
||||||
if #l > 3 then
|
if #l > 3 then
|
||||||
l[1] = tr("MACs")
|
l[1] = _("MACs")
|
||||||
end
|
end
|
||||||
return table.concat(l, "")
|
return table.concat(l, "")
|
||||||
end
|
end
|
||||||
|
@ -47,12 +47,12 @@ end
|
||||||
function fmt_port(x, d)
|
function fmt_port(x, d)
|
||||||
if x and #x > 0 then
|
if x and #x > 0 then
|
||||||
local p, n
|
local p, n
|
||||||
local l = { tr("port"), " " }
|
local l = { _("port"), " " }
|
||||||
for p in ut.imatch(x) do
|
for p in ut.imatch(x) do
|
||||||
p, n = fmt_neg(p)
|
p, n = fmt_neg(p)
|
||||||
local a, b = p:match("(%d+)%D+(%d+)")
|
local a, b = p:match("(%d+)%D+(%d+)")
|
||||||
if a and b then
|
if a and b then
|
||||||
l[1] = tr("ports")
|
l[1] = _("ports")
|
||||||
l[#l+1] = "<var>%s%d-%d</var>" %{ n, a, b }
|
l[#l+1] = "<var>%s%d-%d</var>" %{ n, a, b }
|
||||||
else
|
else
|
||||||
l[#l+1] = "<var>%s%d</var>" %{ n, p }
|
l[#l+1] = "<var>%s%d</var>" %{ n, p }
|
||||||
|
@ -62,7 +62,7 @@ function fmt_port(x, d)
|
||||||
if #l > 1 then
|
if #l > 1 then
|
||||||
l[#l] = nil
|
l[#l] = nil
|
||||||
if #l > 3 then
|
if #l > 3 then
|
||||||
l[1] = tr("ports")
|
l[1] = _("ports")
|
||||||
end
|
end
|
||||||
return table.concat(l, "")
|
return table.concat(l, "")
|
||||||
end
|
end
|
||||||
|
@ -72,7 +72,7 @@ end
|
||||||
|
|
||||||
function fmt_ip(x, d)
|
function fmt_ip(x, d)
|
||||||
if x and #x > 0 then
|
if x and #x > 0 then
|
||||||
local l = { tr("IP"), " " }
|
local l = { _("IP"), " " }
|
||||||
local v, a, n
|
local v, a, n
|
||||||
for v in ut.imatch(x) do
|
for v in ut.imatch(x) do
|
||||||
v, n = fmt_neg(v)
|
v, n = fmt_neg(v)
|
||||||
|
@ -80,7 +80,7 @@ function fmt_ip(x, d)
|
||||||
a = a or v
|
a = a or v
|
||||||
a = a:match(":") and ip.IPv6(a, m) or ip.IPv4(a, m)
|
a = a:match(":") and ip.IPv6(a, m) or ip.IPv4(a, m)
|
||||||
if a and (a:is6() and a:prefix() < 128 or a:prefix() < 32) then
|
if a and (a:is6() and a:prefix() < 128 or a:prefix() < 32) then
|
||||||
l[1] = tr("IP range")
|
l[1] = _("IP range")
|
||||||
l[#l+1] = "<var title='%s - %s'>%s%s</var>" %{
|
l[#l+1] = "<var title='%s - %s'>%s%s</var>" %{
|
||||||
a:minhost():string(),
|
a:minhost():string(),
|
||||||
a:maxhost():string(),
|
a:maxhost():string(),
|
||||||
|
@ -97,7 +97,7 @@ function fmt_ip(x, d)
|
||||||
if #l > 1 then
|
if #l > 1 then
|
||||||
l[#l] = nil
|
l[#l] = nil
|
||||||
if #l > 3 then
|
if #l > 3 then
|
||||||
l[1] = tr("IPs")
|
l[1] = _("IPs")
|
||||||
end
|
end
|
||||||
return table.concat(l, "")
|
return table.concat(l, "")
|
||||||
end
|
end
|
||||||
|
@ -107,7 +107,7 @@ end
|
||||||
|
|
||||||
function fmt_zone(x, d)
|
function fmt_zone(x, d)
|
||||||
if x == "*" then
|
if x == "*" then
|
||||||
return "<var>%s</var>" % tr("any zone")
|
return "<var>%s</var>" % _("any zone")
|
||||||
elseif x and #x > 0 then
|
elseif x and #x > 0 then
|
||||||
return "<var>%s</var>" % x
|
return "<var>%s</var>" % x
|
||||||
elseif d then
|
elseif d then
|
||||||
|
@ -118,7 +118,7 @@ end
|
||||||
function fmt_icmp_type(x)
|
function fmt_icmp_type(x)
|
||||||
if x and #x > 0 then
|
if x and #x > 0 then
|
||||||
local t, v, n
|
local t, v, n
|
||||||
local l = { tr("type"), " " }
|
local l = { _("type"), " " }
|
||||||
for v in ut.imatch(x) do
|
for v in ut.imatch(x) do
|
||||||
v, n = fmt_neg(v)
|
v, n = fmt_neg(v)
|
||||||
l[#l+1] = "<var>%s%s</var>" %{ n, v }
|
l[#l+1] = "<var>%s%s</var>" %{ n, v }
|
||||||
|
@ -127,7 +127,7 @@ function fmt_icmp_type(x)
|
||||||
if #l > 1 then
|
if #l > 1 then
|
||||||
l[#l] = nil
|
l[#l] = nil
|
||||||
if #l > 3 then
|
if #l > 3 then
|
||||||
l[1] = tr("types")
|
l[1] = _("types")
|
||||||
end
|
end
|
||||||
return table.concat(l, "")
|
return table.concat(l, "")
|
||||||
end
|
end
|
||||||
|
@ -180,13 +180,13 @@ function fmt_limit(limit, burst)
|
||||||
u = u or "second"
|
u = u or "second"
|
||||||
if l then
|
if l then
|
||||||
if u:match("^s") then
|
if u:match("^s") then
|
||||||
u = tr("second")
|
u = _("second")
|
||||||
elseif u:match("^m") then
|
elseif u:match("^m") then
|
||||||
u = tr("minute")
|
u = _("minute")
|
||||||
elseif u:match("^h") then
|
elseif u:match("^h") then
|
||||||
u = tr("hour")
|
u = _("hour")
|
||||||
elseif u:match("^d") then
|
elseif u:match("^d") then
|
||||||
u = tr("day")
|
u = _("day")
|
||||||
end
|
end
|
||||||
if burst and burst > 0 then
|
if burst and burst > 0 then
|
||||||
return translatef("<var>%d</var> pkts. per <var>%s</var>, \
|
return translatef("<var>%d</var> pkts. per <var>%s</var>, \
|
||||||
|
@ -201,23 +201,23 @@ end
|
||||||
function fmt_target(x, dest)
|
function fmt_target(x, dest)
|
||||||
if dest and #dest > 0 then
|
if dest and #dest > 0 then
|
||||||
if x == "ACCEPT" then
|
if x == "ACCEPT" then
|
||||||
return tr("Accept forward")
|
return _("Accept forward")
|
||||||
elseif x == "REJECT" then
|
elseif x == "REJECT" then
|
||||||
return tr("Refuse forward")
|
return _("Refuse forward")
|
||||||
elseif x == "NOTRACK" then
|
elseif x == "NOTRACK" then
|
||||||
return tr("Do not track forward")
|
return _("Do not track forward")
|
||||||
else --if x == "DROP" then
|
else --if x == "DROP" then
|
||||||
return tr("Discard forward")
|
return _("Discard forward")
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if x == "ACCEPT" then
|
if x == "ACCEPT" then
|
||||||
return tr("Accept input")
|
return _("Accept input")
|
||||||
elseif x == "REJECT" then
|
elseif x == "REJECT" then
|
||||||
return tr("Refuse input")
|
return _("Refuse input")
|
||||||
elseif x == "NOTRACK" then
|
elseif x == "NOTRACK" then
|
||||||
return tr("Do not track input")
|
return _("Do not track input")
|
||||||
else --if x == "DROP" then
|
else --if x == "DROP" then
|
||||||
return tr("Discard input")
|
return _("Discard input")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -228,12 +228,12 @@ function opt_enabled(s, t, ...)
|
||||||
local o = s:option(t, "__enabled")
|
local o = s:option(t, "__enabled")
|
||||||
function o.render(self, section)
|
function o.render(self, section)
|
||||||
if self.map:get(section, "enabled") ~= "0" then
|
if self.map:get(section, "enabled") ~= "0" then
|
||||||
self.title = tr("Rule is enabled")
|
self.title = _("Rule is enabled")
|
||||||
self.inputtitle = tr("Disable")
|
self.inputtitle = _("Disable")
|
||||||
self.inputstyle = "reset"
|
self.inputstyle = "reset"
|
||||||
else
|
else
|
||||||
self.title = tr("Rule is disabled")
|
self.title = _("Rule is disabled")
|
||||||
self.inputtitle = tr("Enable")
|
self.inputtitle = _("Enable")
|
||||||
self.inputstyle = "apply"
|
self.inputstyle = "apply"
|
||||||
end
|
end
|
||||||
t.render(self, section)
|
t.render(self, section)
|
||||||
|
|
Loading…
Reference in a new issue