X-Git-Url: https://git.archive.openwrt.org/?a=blobdiff_plain;f=libs%2Fweb%2Fluasrc%2Fi18n.lua;h=7ace708e9d721cb964be3fa4a36e449bbf83b168;hb=8f7f03a0c56190b02a8922f01f2c36c62d1dbfe7;hp=3a8a9a6c7659b3403cd36aec3737522d8accaeea;hpb=218ff77599d776dcf47e5522292406ba26130915;p=project%2Fluci.git diff --git a/libs/web/luasrc/i18n.lua b/libs/web/luasrc/i18n.lua index 3a8a9a6c7..7ace708e9 100644 --- a/libs/web/luasrc/i18n.lua +++ b/libs/web/luasrc/i18n.lua @@ -29,6 +29,7 @@ require("luci.sys") table = {} i18ndir = luci.sys.libpath() .. "/i18n/" +loaded = {} -- Clears the translation table function clear() @@ -36,14 +37,19 @@ function clear() end -- Loads a translation and copies its data into the global translation table -function load(file) - local f = loadfile(i18ndir .. file) - if f then - setfenv(f, table) - f() - return true +function load(file, force) + if force or not loaded[file] then + local f = loadfile(i18ndir .. file) + if f then + setfenv(f, table) + f() + loaded[file] = true + return true + else + return false + end else - return false + return true end end