From bab4af01ebf0709f951b9d16c993a0c9926e9b9e Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sat, 20 Jul 2019 20:52:18 +0200 Subject: [PATCH] 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 --- package/gluon-web-network/i18n/de.po | 3 +++ package/gluon-web-network/i18n/fr.po | 3 +++ .../i18n/gluon-web-network.pot | 3 +++ .../gluon/config-mode/model/admin/network.lua | 20 ++++++++++++++----- 4 files changed, 24 insertions(+), 5 deletions(-) diff --git a/package/gluon-web-network/i18n/de.po b/package/gluon-web-network/i18n/de.po index 1170cbb0..4a6bc8b5 100644 --- a/package/gluon-web-network/i18n/de.po +++ b/package/gluon-web-network/i18n/de.po @@ -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" diff --git a/package/gluon-web-network/i18n/fr.po b/package/gluon-web-network/i18n/fr.po index c67531d8..292d6e25 100644 --- a/package/gluon-web-network/i18n/fr.po +++ b/package/gluon-web-network/i18n/fr.po @@ -19,6 +19,9 @@ msgstr "Automatique (RA/DHCPv6)" msgid "Disabled" msgstr "Désactivé" +msgid "Enable \"%s\"" +msgstr "" + msgid "Enable PoE Passthrough" msgstr "" diff --git a/package/gluon-web-network/i18n/gluon-web-network.pot b/package/gluon-web-network/i18n/gluon-web-network.pot index 75f625da..913b78b3 100644 --- a/package/gluon-web-network/i18n/gluon-web-network.pot +++ b/package/gluon-web-network/i18n/gluon-web-network.pot @@ -10,6 +10,9 @@ msgstr "" msgid "Disabled" msgstr "" +msgid "Enable \"%s\"" +msgstr "" + msgid "Enable PoE Passthrough" msgstr "" diff --git a/package/gluon-web-network/luasrc/lib/gluon/config-mode/model/admin/network.lua b/package/gluon-web-network/luasrc/lib/gluon/config-mode/model/admin/network.lua index 2d8a3a2c..7bd1aff6 100644 --- a/package/gluon-web-network/luasrc/lib/gluon/config-mode/model/admin/network.lua +++ b/package/gluon-web-network/luasrc/lib/gluon/config-mode/model/admin/network.lua @@ -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")