gluon-web-network: improve PoE GPIO name translation handling

- Replace string concat for i18n key with an explicit list to make the code
  compatible with i18n-scan.pl
- Improve fallback string
This commit is contained in:
Matthias Schiffer 2019-07-20 20:52:18 +02:00
parent df5bf20b6c
commit bab4af01eb
No known key found for this signature in database
GPG Key ID: 16EF3F64CB201D9C
4 changed files with 24 additions and 5 deletions

View File

@ -19,6 +19,9 @@ msgstr "Automatisch (RA/DHCPv6)"
msgid "Disabled"
msgstr "Deaktiviert"
msgid "Enable \"%s\""
msgstr "\"%s\" aktivieren"
msgid "Enable PoE Passthrough"
msgstr "PoE-Passthrough aktivieren"

View File

@ -19,6 +19,9 @@ msgstr "Automatique (RA/DHCPv6)"
msgid "Disabled"
msgstr "Désactivé"
msgid "Enable \"%s\""
msgstr ""
msgid "Enable PoE Passthrough"
msgstr ""

View File

@ -10,6 +10,9 @@ msgstr ""
msgid "Disabled"
msgstr ""
msgid "Enable \"%s\""
msgstr ""
msgid "Enable PoE Passthrough"
msgstr ""

View File

@ -113,13 +113,23 @@ uci:foreach("system", "gpio_switch", function(si)
section = f:section(Section)
end
local port = si.name:match("^PoE Power Port(%d*)$")
local texts = {
["^PoE Power Port(%d*)$"] = function(m) return translatef("Enable PoE Power Port %s", m[1]) end,
["^PoE Passthrough$"] = function() return translate("Enable PoE Passthrough") end,
}
local name
if port then
name = translatef("Enable PoE Power Port %s", port)
else
name = translate("Enable " .. si.name)
for pattern, f in pairs(texts) do
local match = {si.name:match(pattern)}
if match[1] then
name = f(match)
break
end
end
if not name then
name = translatef('Enable "%s"', si.name)
end
local poe = section:option(Flag, si[".name"], name)
poe.default = uci:get_bool("system", si[".name"], "value")