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" msgid "Disabled"
msgstr "Deaktiviert" msgstr "Deaktiviert"
msgid "Enable \"%s\""
msgstr "\"%s\" aktivieren"
msgid "Enable PoE Passthrough" msgid "Enable PoE Passthrough"
msgstr "PoE-Passthrough aktivieren" msgstr "PoE-Passthrough aktivieren"

View File

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

View File

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

View File

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