From 8fe70a00b47c0059a55d35d1647ad06a8b9b0ad0 Mon Sep 17 00:00:00 2001 From: nrb <38812627+nrbffs@users.noreply.github.com> Date: Sat, 15 Dec 2018 17:25:43 +0100 Subject: [PATCH] gluon-config-mode-zip: i18n: fix translations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use the correct translation namespace. As we run in gluon config mode, we do not have our own controller. Thus we need to specify the translation namespace for gluon to find translations. See <https://gluon.readthedocs.io/en/stable/dev/web/i18n.html>: > Note that translations are namespaced: each package will only use its > own translation strings by default. For this purpose, the package name > must by specified in a package’s controller. It is possible to access > a different translation package using the i18n function from models > and view, which is necessary when strings from the site configuration > are used, or packages do not have their own controller (which is the > case for config mode wizard components). > > local site_i18n = i18n 'gluon-site' > local msg = site_i18n._translate('gluon-config-mode:welcome') > --- .../lib/gluon/config-mode/wizard/0450-geo-location.lua | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/gluon-config-mode-zip/luasrc/lib/gluon/config-mode/wizard/0450-geo-location.lua b/gluon-config-mode-zip/luasrc/lib/gluon/config-mode/wizard/0450-geo-location.lua index ace7469..1197beb 100644 --- a/gluon-config-mode-zip/luasrc/lib/gluon/config-mode/wizard/0450-geo-location.lua +++ b/gluon-config-mode-zip/luasrc/lib/gluon/config-mode/wizard/0450-geo-location.lua @@ -1,11 +1,12 @@ return function(form, uci) local location = uci:get_first("gluon-node-info", "location") - local text = translate("gluon-config-mode:zip-help") + local site_i18n = i18n 'gluon-site' + local text = site_i18n.translate("gluon-config-mode:zip-help") local s = form:section(Section, nil, text) - local o = s:option(Value, "zip", translate("ZIP-Code"), translatef("e.g. %s", "70499")) + local o = s:option(Value, "zip", site_i18n.translate("ZIP-Code"), site_i18n.translatef("e.g. %s", "70499")) o.default = uci:get("gluon-node-info", location, "zip") o.datatype = "uinteger" o.optional = true @@ -14,4 +15,4 @@ return function(form, uci) end return {'gluon-node-info'} -end \ No newline at end of file +end -- GitLab