Skip to content
Snippets Groups Projects
Unverified Commit 557565e1 authored by Matthias Schiffer's avatar Matthias Schiffer
Browse files

gluon-web: add i18n package namespaces

parent 1a426c3b
No related branches found
No related tags found
No related merge requests found
Showing
with 77 additions and 30 deletions
return function(form, uci) return function(form, uci)
local pkg_i18n = i18n 'gluon-config-mode-autoupdater'
local enabled = uci:get_bool("autoupdater", "settings", "enabled") local enabled = uci:get_bool("autoupdater", "settings", "enabled")
if enabled then if enabled then
form:section( form:section(
Section, nil, Section, nil,
translate('This node will automatically update its firmware when a new version is available.') pkg_i18n.translate('This node will automatically update its firmware when a new version is available.')
) )
else else
form:section( form:section(
Section, nil, Section, nil,
translate('Automatic updates are disabled. They can be enabled in <em>Advanced settings</em>.') pkg_i18n.translate('Automatic updates are disabled. They can be enabled in <em>Advanced settings</em>.')
) )
end end
end end
return function(form, uci) return function(form, uci)
local pkg_i18n = i18n 'gluon-config-mode-contact-info'
local site = require 'gluon.site' local site = require 'gluon.site'
local owner = uci:get_first("gluon-node-info", "owner") local owner = uci:get_first("gluon-node-info", "owner")
local s = form:section(Section, nil, translate( local s = form:section(Section, nil, pkg_i18n.translate(
'Please provide your contact information here to ' 'Please provide your contact information here to '
.. 'allow others to contact you. Note that ' .. 'allow others to contact you. Note that '
.. 'this information will be visible <em>publicly</em> ' .. 'this information will be visible <em>publicly</em> '
.. 'on the internet together with your node\'s coordinates.' .. 'on the internet together with your node\'s coordinates.'
)) ))
local o = s:option(Value, "contact", translate("Contact info"), translate("e.g. E-mail or phone number")) local o = s:option(Value, "contact", pkg_i18n.translate("Contact info"), pkg_i18n.translate("e.g. E-mail or phone number"))
o.default = uci:get("gluon-node-info", owner, "contact") o.default = uci:get("gluon-node-info", owner, "contact")
o.optional = not site.config_mode.owner.obligatory(false) o.optional = not site.config_mode.owner.obligatory(false)
-- without a minimal length, an empty string will be accepted even with "optional = false" -- without a minimal length, an empty string will be accepted even with "optional = false"
......
<%- <%-
local site_i18n = i18n 'gluon-site'
local sysconfig = require 'gluon.sysconfig' local sysconfig = require 'gluon.sysconfig'
local msg = _translate('gluon-config-mode:welcome') local msg = site_i18n._translate('gluon-config-mode:welcome')
if not msg then return end if not msg then return end
-%> -%>
<p> <p>
......
local site_i18n = i18n 'gluon-site'
local site = require 'gluon.site' local site = require 'gluon.site'
local sysconfig = require 'gluon.sysconfig' local sysconfig = require 'gluon.sysconfig'
local pretty_hostname = require 'pretty_hostname' local pretty_hostname = require 'pretty_hostname'
...@@ -7,7 +9,7 @@ local uci = require("simple-uci").cursor() ...@@ -7,7 +9,7 @@ local uci = require("simple-uci").cursor()
local hostname = pretty_hostname.get(uci) local hostname = pretty_hostname.get(uci)
local contact = uci:get_first('gluon-node-info', 'owner', 'contact') local contact = uci:get_first('gluon-node-info', 'owner', 'contact')
local msg = _translate('gluon-config-mode:reboot') local msg = site_i18n._translate('gluon-config-mode:reboot')
if not msg then return end if not msg then return end
renderer.render_string(msg, { renderer.render_string(msg, {
......
package 'gluon-config-mode-core'
entry({}, alias("wizard")) entry({}, alias("wizard"))
entry({"wizard"}, model("gluon-config-mode/wizard"), _("Wizard"), 5) entry({"wizard"}, model("gluon-config-mode/wizard"), _("Wizard"), 5)
...@@ -26,6 +26,7 @@ f.reset = false ...@@ -26,6 +26,7 @@ f.reset = false
local s = f:section(Section) local s = f:section(Section)
s.template = "gluon/config-mode/welcome" s.template = "gluon/config-mode/welcome"
s.package = "gluon-config-mode-core"
local commit = {'gluon-setup-mode'} local commit = {'gluon-setup-mode'}
local run = {} local run = {}
...@@ -57,6 +58,7 @@ function f:write() ...@@ -57,6 +58,7 @@ function f:write()
end end
f.template = "gluon/config-mode/reboot" f.template = "gluon/config-mode/reboot"
f.package = "gluon-config-mode-core"
f.hidenav = true f.hidenav = true
if nixio.fork() == 0 then if nixio.fork() == 0 then
......
return function(form, uci) return function(form, uci)
local site_i18n = i18n 'gluon-site'
local fs = require 'nixio.fs' local fs = require 'nixio.fs'
local json = require 'jsonc' local json = require 'jsonc'
local site = require 'gluon.site' local site = require 'gluon.site'
...@@ -24,8 +26,8 @@ return function(form, uci) ...@@ -24,8 +26,8 @@ return function(form, uci)
return list return list
end end
local s = form:section(Section, nil, translate('gluon-config-mode:domain-select')) local s = form:section(Section, nil, site_i18n.translate('gluon-config-mode:domain-select'))
local o = s:option(ListValue, 'domain', translate('gluon-config-mode:domain')) local o = s:option(ListValue, 'domain', site_i18n.translate('gluon-config-mode:domain'))
if configured then if configured then
o.default = selected_domain o.default = selected_domain
......
return function(form, uci) return function(form, uci)
local pkg_i18n = i18n 'gluon-config-mode-geo-location'
local site_i18n = i18n 'gluon-site'
local site = require 'gluon.site' local site = require 'gluon.site'
local location = uci:get_first("gluon-node-info", "location") local location = uci:get_first("gluon-node-info", "location")
...@@ -11,25 +14,25 @@ return function(form, uci) ...@@ -11,25 +14,25 @@ return function(form, uci)
return uci:get_bool("gluon-node-info", location, "altitude") return uci:get_bool("gluon-node-info", location, "altitude")
end end
local text = translate( local text = pkg_i18n.translate(
'If you want the location of your node to ' .. 'If you want the location of your node to ' ..
'be displayed on the map, you can enter its coordinates here.' 'be displayed on the map, you can enter its coordinates here.'
) )
if show_altitude() then if show_altitude() then
text = text .. ' ' .. translate("gluon-config-mode:altitude-help") text = text .. ' ' .. site_i18n.translate("gluon-config-mode:altitude-help")
end end
local s = form:section(Section, nil, text) local s = form:section(Section, nil, text)
local o local o
local share_location = s:option(Flag, "location", translate("Show node on the map")) local share_location = s:option(Flag, "location", pkg_i18n.translate("Show node on the map"))
share_location.default = uci:get_bool("gluon-node-info", location, "share_location") share_location.default = uci:get_bool("gluon-node-info", location, "share_location")
function share_location:write(data) function share_location:write(data)
uci:set("gluon-node-info", location, "share_location", data) uci:set("gluon-node-info", location, "share_location", data)
end end
o = s:option(Value, "latitude", translate("Latitude"), translatef("e.g. %s", "53.873621")) o = s:option(Value, "latitude", pkg_i18n.translate("Latitude"), pkg_i18n.translatef("e.g. %s", "53.873621"))
o.default = uci:get("gluon-node-info", location, "latitude") o.default = uci:get("gluon-node-info", location, "latitude")
o:depends(share_location, true) o:depends(share_location, true)
o.datatype = "float" o.datatype = "float"
...@@ -37,7 +40,7 @@ return function(form, uci) ...@@ -37,7 +40,7 @@ return function(form, uci)
uci:set("gluon-node-info", location, "latitude", data) uci:set("gluon-node-info", location, "latitude", data)
end end
o = s:option(Value, "longitude", translate("Longitude"), translatef("e.g. %s", "10.689901")) o = s:option(Value, "longitude", pkg_i18n.translate("Longitude"), pkg_i18n.translatef("e.g. %s", "10.689901"))
o.default = uci:get("gluon-node-info", location, "longitude") o.default = uci:get("gluon-node-info", location, "longitude")
o:depends(share_location, true) o:depends(share_location, true)
o.datatype = "float" o.datatype = "float"
...@@ -46,7 +49,7 @@ return function(form, uci) ...@@ -46,7 +49,7 @@ return function(form, uci)
end end
if show_altitude() then if show_altitude() then
o = s:option(Value, "altitude", translate("gluon-config-mode:altitude-label"), translatef("e.g. %s", "11.51")) o = s:option(Value, "altitude", site_i18n.translate("gluon-config-mode:altitude-label"), pkg_i18n.translatef("e.g. %s", "11.51"))
o.default = uci:get("gluon-node-info", location, "altitude") o.default = uci:get("gluon-node-info", location, "altitude")
o:depends(share_location, true) o:depends(share_location, true)
o.datatype = "float" o.datatype = "float"
......
return function(form, uci) return function(form, uci)
local pkg_i18n = i18n 'gluon-config-mode-hostname'
local pretty_hostname = require "pretty_hostname" local pretty_hostname = require "pretty_hostname"
local s = form:section(Section) local s = form:section(Section)
local o = s:option(Value, "hostname", translate("Node name")) local o = s:option(Value, "hostname", pkg_i18n.translate("Node name"))
o.default = pretty_hostname.get(uci) o.default = pretty_hostname.get(uci)
function o:write(data) function o:write(data)
......
local site_i18n = i18n 'gluon-site'
local uci = require("simple-uci").cursor() local uci = require("simple-uci").cursor()
local lutil = require "gluon.web.util" local lutil = require "gluon.web.util"
local fs = require "nixio.fs" local fs = require "nixio.fs"
...@@ -23,15 +25,15 @@ local msg ...@@ -23,15 +25,15 @@ local msg
if has_tunneldigger then if has_tunneldigger then
local tunneldigger_enabled = uci:get_bool("tunneldigger", "mesh_vpn", "enabled") local tunneldigger_enabled = uci:get_bool("tunneldigger", "mesh_vpn", "enabled")
if not tunneldigger_enabled then if not tunneldigger_enabled then
msg = _translate('gluon-config-mode:novpn') msg = site_i18n._translate('gluon-config-mode:novpn')
end end
elseif has_fastd then elseif has_fastd then
local fastd_enabled = uci:get_bool("fastd", "mesh_vpn", "enabled") local fastd_enabled = uci:get_bool("fastd", "mesh_vpn", "enabled")
if fastd_enabled then if fastd_enabled then
pubkey = util.trim(lutil.exec("/etc/init.d/fastd show_key mesh_vpn")) pubkey = util.trim(lutil.exec("/etc/init.d/fastd show_key mesh_vpn"))
msg = _translate('gluon-config-mode:pubkey') msg = site_i18n._translate('gluon-config-mode:pubkey')
else else
msg = _translate('gluon-config-mode:novpn') msg = site_i18n._translate('gluon-config-mode:novpn')
end end
end end
......
...@@ -8,7 +8,9 @@ return function(form, uci) ...@@ -8,7 +8,9 @@ return function(form, uci)
return return
end end
local msg = translate( local pkg_i18n = i18n 'gluon-config-mode-mesh-vpn'
local msg = pkg_i18n.translate(
'Your internet connection can be used to establish a ' .. 'Your internet connection can be used to establish a ' ..
'VPN connection with other nodes. ' .. 'VPN connection with other nodes. ' ..
'Enable this option if there are no other nodes reachable ' .. 'Enable this option if there are no other nodes reachable ' ..
...@@ -21,7 +23,7 @@ return function(form, uci) ...@@ -21,7 +23,7 @@ return function(form, uci)
local o local o
local meshvpn = s:option(Flag, "meshvpn", translate("Use internet connection (mesh VPN)")) local meshvpn = s:option(Flag, "meshvpn", pkg_i18n.translate("Use internet connection (mesh VPN)"))
meshvpn.default = uci:get_bool("fastd", "mesh_vpn", "enabled") or uci:get_bool("tunneldigger", "mesh_vpn", "enabled") meshvpn.default = uci:get_bool("fastd", "mesh_vpn", "enabled") or uci:get_bool("tunneldigger", "mesh_vpn", "enabled")
function meshvpn:write(data) function meshvpn:write(data)
if has_fastd then if has_fastd then
...@@ -32,7 +34,7 @@ return function(form, uci) ...@@ -32,7 +34,7 @@ return function(form, uci)
end end
end end
local limit = s:option(Flag, "limit_enabled", translate("Limit bandwidth")) local limit = s:option(Flag, "limit_enabled", pkg_i18n.translate("Limit bandwidth"))
limit:depends(meshvpn, true) limit:depends(meshvpn, true)
limit.default = uci:get_bool("simple-tc", "mesh_vpn", "enabled") limit.default = uci:get_bool("simple-tc", "mesh_vpn", "enabled")
function limit:write(data) function limit:write(data)
...@@ -41,7 +43,7 @@ return function(form, uci) ...@@ -41,7 +43,7 @@ return function(form, uci)
uci:set("simple-tc", "mesh_vpn", "ifname", "mesh-vpn") uci:set("simple-tc", "mesh_vpn", "ifname", "mesh-vpn")
end end
o = s:option(Value, "limit_ingress", translate("Downstream (kbit/s)")) o = s:option(Value, "limit_ingress", pkg_i18n.translate("Downstream (kbit/s)"))
o:depends(limit, true) o:depends(limit, true)
o.default = uci:get("simple-tc", "mesh_vpn", "limit_ingress") o.default = uci:get("simple-tc", "mesh_vpn", "limit_ingress")
o.datatype = "uinteger" o.datatype = "uinteger"
...@@ -49,7 +51,7 @@ return function(form, uci) ...@@ -49,7 +51,7 @@ return function(form, uci)
uci:set("simple-tc", "mesh_vpn", "limit_ingress", data) uci:set("simple-tc", "mesh_vpn", "limit_ingress", data)
end end
o = s:option(Value, "limit_egress", translate("Upstream (kbit/s)")) o = s:option(Value, "limit_egress", pkg_i18n.translate("Upstream (kbit/s)"))
o:depends(limit, true) o:depends(limit, true)
o.default = uci:get("simple-tc", "mesh_vpn", "limit_egress") o.default = uci:get("simple-tc", "mesh_vpn", "limit_egress")
o.datatype = "uinteger" o.datatype = "uinteger"
......
package 'gluon-web-admin'
local root = node() local root = node()
if not root.target then if not root.target then
root.target = alias("admin") root.target = alias("admin")
......
...@@ -9,6 +9,9 @@ You may obtain a copy of the License at ...@@ -9,6 +9,9 @@ You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 http://www.apache.org/licenses/LICENSE-2.0
]]-- ]]--
package 'gluon-web-admin'
local fs = require 'nixio.fs' local fs = require 'nixio.fs'
local tmpfile = "/tmp/firmware.img" local tmpfile = "/tmp/firmware.img"
...@@ -106,17 +109,23 @@ local function action_upgrade(http, renderer) ...@@ -106,17 +109,23 @@ local function action_upgrade(http, renderer)
renderer.render("layout", { renderer.render("layout", {
content = "admin/upgrade", content = "admin/upgrade",
bad_image = has_image and not has_support, env = {
bad_image = has_image and not has_support,
},
pkg = 'gluon-web-admin',
}) })
-- Step 2: present uploaded file, show checksum, confirmation -- Step 2: present uploaded file, show checksum, confirmation
elseif step == 2 then elseif step == 2 then
renderer.render("layout", { renderer.render("layout", {
content = "admin/upgrade_confirm", content = "admin/upgrade_confirm",
checksum = image_checksum(tmpfile), env = {
filesize = fs.stat(tmpfile).size, checksum = image_checksum(tmpfile),
flashsize = storage_size(), filesize = fs.stat(tmpfile).size,
keepconfig = (http:formvalue("keepcfg") == "1"), flashsize = storage_size(),
keepconfig = (http:formvalue("keepcfg") == "1"),
},
pkg = 'gluon-web-admin',
}) })
elseif step == 3 then elseif step == 3 then
if http:formvalue("keepcfg") == "1" then if http:formvalue("keepcfg") == "1" then
...@@ -127,6 +136,7 @@ local function action_upgrade(http, renderer) ...@@ -127,6 +136,7 @@ local function action_upgrade(http, renderer)
renderer.render("layout", { renderer.render("layout", {
content = "admin/upgrade_reboot", content = "admin/upgrade_reboot",
hidenav = true, hidenav = true,
pkg = 'gluon-web-admin',
}) })
end end
end end
......
package 'gluon-web-autoupdater'
entry({"admin", "autoupdater"}, model("admin/autoupdater"), _("Automatic updates"), 80) entry({"admin", "autoupdater"}, model("admin/autoupdater"), _("Automatic updates"), 80)
package 'gluon-web-logging'
entry({"admin", "logging"}, model("admin/logging"), _("Logging"), 85) entry({"admin", "logging"}, model("admin/logging"), _("Logging"), 85)
...@@ -26,14 +26,14 @@ define Build/Configure ...@@ -26,14 +26,14 @@ define Build/Configure
endef endef
define Build/Compile define Build/Compile
$(call GluonBuildI18N,gluon-mesh-vpn-fastd,i18n) $(call GluonBuildI18N,gluon-web-mesh-vpn-fastd,i18n)
$(call GluonSrcDiet,./luasrc,$(PKG_BUILD_DIR)/luadest/) $(call GluonSrcDiet,./luasrc,$(PKG_BUILD_DIR)/luadest/)
endef endef
define Package/gluon-web-mesh-vpn-fastd/install define Package/gluon-web-mesh-vpn-fastd/install
$(CP) ./files/* $(1)/ $(CP) ./files/* $(1)/
$(CP) $(PKG_BUILD_DIR)/luadest/* $(1)/ $(CP) $(PKG_BUILD_DIR)/luadest/* $(1)/
$(call GluonInstallI18N,gluon-mesh-vpn-fastd,$(1)) $(call GluonInstallI18N,gluon-web-mesh-vpn-fastd,$(1))
endef endef
define Package/gluon-web-mesh-vpn-fastd/postinst define Package/gluon-web-mesh-vpn-fastd/postinst
......
package 'gluon-web-mesh-vpn-fastd'
entry({"admin", "mesh_vpn_fastd"}, model("admin/mesh_vpn_fastd"), _("Mesh VPN"), 50) entry({"admin", "mesh_vpn_fastd"}, model("admin/mesh_vpn_fastd"), _("Mesh VPN"), 50)
...@@ -6,6 +6,7 @@ local f = Form(translate('Mesh VPN')) ...@@ -6,6 +6,7 @@ local f = Form(translate('Mesh VPN'))
local s = f:section(Section) local s = f:section(Section)
local mode = s:option(Value, 'mode') local mode = s:option(Value, 'mode')
mode.package = "gluon-web-mesh-vpn-fastd"
mode.template = "gluon/model/mesh-vpn-fastd" mode.template = "gluon/model/mesh-vpn-fastd"
local methods = uci:get('fastd', 'mesh_vpn', 'method') local methods = uci:get('fastd', 'mesh_vpn', 'method')
......
package 'gluon-web-network'
entry({"admin", "network"}, model("admin/network"), _("Network"), 40) entry({"admin", "network"}, model("admin/network"), _("Network"), 40)
package 'gluon-web-node-role'
entry({"admin", "noderole"}, model("admin/noderole"), "Node role", 60) entry({"admin", "noderole"}, model("admin/noderole"), "Node role", 60)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment