gluon-luci-node-role: make node role display strings translatable
This commit is contained in:
parent
82983c871e
commit
1b7c3e060b
@ -39,6 +39,19 @@ Site changes
|
||||
}
|
||||
}
|
||||
|
||||
- ``roles``: The display strings for the node roles aren't configured in the ``site.conf`` anymore, but
|
||||
in the site i18n files. The ``site.conf`` section becomes::
|
||||
|
||||
roles = {
|
||||
default = 'foo',
|
||||
list = {
|
||||
'foo',
|
||||
'bar',
|
||||
}
|
||||
}
|
||||
|
||||
The display string use i18n message IDs like ``gluon-luci-node-role:role:foo`` and ``gluon-luci-node-role:role:bar``.
|
||||
|
||||
|
||||
* ``site.mk``
|
||||
|
||||
|
@ -154,13 +154,13 @@
|
||||
},
|
||||
|
||||
-- Node roles
|
||||
-- roles {
|
||||
-- roles = {
|
||||
-- default = 'node',
|
||||
-- list = {
|
||||
-- node = 'Normal Node',
|
||||
-- test = 'Test Node',
|
||||
-- backbone = 'Backbone Node',
|
||||
-- service = 'Service Node',
|
||||
-- 'node',
|
||||
-- 'test',
|
||||
-- 'backbone',
|
||||
-- 'service',
|
||||
-- },
|
||||
-- },
|
||||
|
||||
|
@ -150,15 +150,19 @@ roles : optional
|
||||
``default`` takes the default role which is set initially. This value should be
|
||||
part of ``list``. If you want node owners to change the role via config mode add
|
||||
the package ``gluon-luci-node-role`` to ``site.mk``.
|
||||
|
||||
The strings to display in the LuCI interface can be configured per language in the
|
||||
``i18n/en.po``, ``i18n/de.po``, etc. files of the site repository using message IDs like
|
||||
``gluon-luci-node-role:role:node`` and ``gluon-luci-node-role:role:backbone``.
|
||||
::
|
||||
|
||||
roles = {
|
||||
default = 'node',
|
||||
list = {
|
||||
node = 'Normal Node',
|
||||
test = 'Test Node',
|
||||
backbone = 'Backbone Node',
|
||||
service = 'Service Node',
|
||||
'node',
|
||||
'test',
|
||||
'backbone',
|
||||
'service',
|
||||
},
|
||||
},
|
||||
|
||||
|
@ -1,8 +1,2 @@
|
||||
local function check_role(k, _)
|
||||
local role = string.format('roles.list[%q]', k)
|
||||
|
||||
need_string(role)
|
||||
end
|
||||
|
||||
need_string('roles.default')
|
||||
need_table('roles.list', check_role)
|
||||
need_string 'roles.default'
|
||||
need_string_array 'roles.list'
|
||||
|
@ -18,8 +18,8 @@ s = f:section(SimpleSection, nil, i18n.translate(
|
||||
o = s:option(ListValue, "role", i18n.translate("Role"))
|
||||
o.default = role
|
||||
o.rmempty = false
|
||||
for role, prettyname in pairs(site.roles.list) do
|
||||
o:value(role, prettyname)
|
||||
for _, role in ipairs(site.roles.list) do
|
||||
o:value(role, i18n.translate('gluon-luci-node-role:role:' .. role))
|
||||
end
|
||||
|
||||
function f.handle(self, state, data)
|
||||
|
@ -1,8 +1 @@
|
||||
local function check_role(k, _)
|
||||
local role = string.format('roles.list[%q]', k)
|
||||
|
||||
need_string(role)
|
||||
end
|
||||
|
||||
need_string('roles.default', false)
|
||||
need_table('roles.list', check_role, false)
|
||||
|
Loading…
Reference in New Issue
Block a user