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
This commit is contained in:
parent
0cb0742818
commit
c1d69d0146
1 changed files with 7 additions and 1 deletions
|
@ -250,7 +250,7 @@ function dispatch(request)
|
||||||
tpl.context.viewns = setmetatable({
|
tpl.context.viewns = setmetatable({
|
||||||
write = luci.http.write;
|
write = luci.http.write;
|
||||||
include = function(name) tpl.Template(name):render(getfenv(2)) end;
|
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;
|
export = function(k, v) if tpl.context.viewns[k] == nil then tpl.context.viewns[k] = v end end;
|
||||||
striptags = util.striptags;
|
striptags = util.striptags;
|
||||||
pcdata = util.pcdata;
|
pcdata = util.pcdata;
|
||||||
|
@ -853,3 +853,9 @@ end
|
||||||
function form(model)
|
function form(model)
|
||||||
return {type = "cbi", model = model, target = _form}
|
return {type = "cbi", model = model, target = _form}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Access the luci.i18n translate() api.
|
||||||
|
-- @class function
|
||||||
|
-- @name translate
|
||||||
|
-- @param text Text to translate
|
||||||
|
translate = i18n.translate
|
||||||
|
|
Loading…
Reference in a new issue