summaryrefslogtreecommitdiffhomepage
path: root/libs/web/luasrc
diff options
context:
space:
mode:
Diffstat (limited to 'libs/web/luasrc')
-rw-r--r--libs/web/luasrc/dispatcher.lua1
-rw-r--r--libs/web/luasrc/i18n.lua28
2 files changed, 13 insertions, 16 deletions
diff --git a/libs/web/luasrc/dispatcher.lua b/libs/web/luasrc/dispatcher.lua
index ad4f24dc7..6445c124e 100644
--- a/libs/web/luasrc/dispatcher.lua
+++ b/libs/web/luasrc/dispatcher.lua
@@ -235,6 +235,7 @@ function dispatch(request)
include = function(name) tpl.Template(name):render(getfenv(2)) end;
translate = function(...) return require("luci.i18n").translate(...) end;
striptags = util.striptags;
+ pcdata = util.pcdata;
media = media;
theme = fs.basename(media);
resource = luci.config.main.resourcebase
diff --git a/libs/web/luasrc/i18n.lua b/libs/web/luasrc/i18n.lua
index 9a11a9dc8..816d90310 100644
--- a/libs/web/luasrc/i18n.lua
+++ b/libs/web/luasrc/i18n.lua
@@ -93,42 +93,38 @@ function setlanguage(lang)
end
--- Return the translated value for a specific translation key.
--- @param key Translation key
--- @param def Default translation
+-- @param key Default translation text
-- @return Translated string
-function translate(key, def)
+function translate(key)
return (table[context.lang] and table[context.lang][key])
or (table[context.parent] and table[context.parent][key])
or (table[default] and table[default][key])
- or def
+ or key
end
--- Return the translated value for a specific translation key and use it as sprintf pattern.
--- @param key Translation key
--- @param default Default translation
+-- @param key Default translation text
-- @param ... Format parameters
-- @return Translated and formatted string
-function translatef(key, default, ...)
- return tostring(translate(key, default)):format(...)
+function translatef(key, ...)
+ return tostring(translate(key)):format(...)
end
--- Return the translated value for a specific translation key
-- and ensure that the returned value is a Lua string value.
-- This is the same as calling <code>tostring(translate(...))</code>
--- @param key Translation key
--- @param default Default translation
+-- @param key Default translation text
-- @return Translated string
-function string(key, default)
- return tostring(translate(key, default))
+function string(key)
+ return tostring(translate(key))
end
--- Return the translated value for a specific translation key and use it as sprintf pattern.
-- Ensure that the returned value is a Lua string value.
-- This is the same as calling <code>tostring(translatef(...))</code>
--- @param key Translation key
--- @param default Default translation
+-- @param key Default translation text
-- @param ... Format parameters
-- @return Translated and formatted string
-function stringf(key, default, ...)
- return tostring(translate(key, default)):format(...)
+function stringf(key, ...)
+ return tostring(translate(key)):format(...)
end