summaryrefslogtreecommitdiffhomepage
path: root/libs/web/luasrc
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2011-08-12 11:13:39 +0000
committerJo-Philipp Wich <jow@openwrt.org>2011-08-12 11:13:39 +0000
commitc1d69d0146f05c41a9ab0e8951947e57b3b77174 (patch)
treec022c13d281f3858dcf2a3eb98ffc0c0412ee3e5 /libs/web/luasrc
parent0cb07428181f485ce666ad55a528d6a831b062a7 (diff)
libs/web: optimize access to translate() api by directly reusing the luci.i18n instance loaded in dispatcher - this saves one extra function call, one extra require and one extra table lookup for _each_ translation string
Diffstat (limited to 'libs/web/luasrc')
-rw-r--r--libs/web/luasrc/dispatcher.lua8
1 files changed, 7 insertions, 1 deletions
diff --git a/libs/web/luasrc/dispatcher.lua b/libs/web/luasrc/dispatcher.lua
index a4ed4b8de..5fdd0a638 100644
--- a/libs/web/luasrc/dispatcher.lua
+++ b/libs/web/luasrc/dispatcher.lua
@@ -250,7 +250,7 @@ function dispatch(request)
tpl.context.viewns = setmetatable({
write = luci.http.write;
include = function(name) tpl.Template(name):render(getfenv(2)) end;
- translate = function(...) return require("luci.i18n").translate(...) end;
+ translate = i18n.translate;
export = function(k, v) if tpl.context.viewns[k] == nil then tpl.context.viewns[k] = v end end;
striptags = util.striptags;
pcdata = util.pcdata;
@@ -853,3 +853,9 @@ end
function form(model)
return {type = "cbi", model = model, target = _form}
end
+
+--- Access the luci.i18n translate() api.
+-- @class function
+-- @name translate
+-- @param text Text to translate
+translate = i18n.translate