webmcp
diff framework/env/locale/_get_translation_table.lua @ 309:4e69ce9a6365
Mechanism to load, compile, and cache Lua code from the filesystem
author | jbe |
---|---|
date | Sun Mar 22 22:25:37 2015 +0100 (2015-03-22) |
parents | 2cb27106aa73 |
children | ba68ef9e7c90 |
line diff
1.1 --- a/framework/env/locale/_get_translation_table.lua Sun Mar 22 20:39:13 2015 +0100 1.2 +++ b/framework/env/locale/_get_translation_table.lua Sun Mar 22 22:25:37 2015 +0100 1.3 @@ -9,12 +9,9 @@ 1.4 return translation_table 1.5 end 1.6 local filename = encode.file_path(WEBMCP_BASE_PATH, "locale", "translations." .. language_code .. ".lua") 1.7 - local func 1.8 - if _ENV then 1.9 - func = assert(loadfile(filename), nil, {}) 1.10 - else 1.11 - func = assert(loadfile(filename)) 1.12 - setfenv(func, {}) 1.13 + local func, load_errmsg = loadcached(filename) 1.14 + if not func then 1.15 + error('Could not load translation file "' .. filename .. '": ' .. load_errmsg) 1.16 end 1.17 translation_table = func() 1.18 if type(translation_table) ~= "table" then