libs/web: optimize access to translate() api by directly reusing the luci.i18n instan...
authorJo-Philipp Wich <jow@openwrt.org>
Fri, 12 Aug 2011 11:13:39 +0000 (11:13 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Fri, 12 Aug 2011 11:13:39 +0000 (11:13 +0000)
libs/web/luasrc/dispatcher.lua

index a4ed4b8def131523ceb5540d3c4a5c1f408e4e2e..5fdd0a6383fdca06d1c076e264ace27e9002be82 100644 (file)
@@ -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