webmcp

view framework/env/locale/do_with.lua @ 380:16baed4c0483

Extended _column_info table to be an associative array as well (in addition to a sequence); Allow direct (proxy) access to fields of JSON object in a special column (completed write access)
author jbe
date Mon Nov 16 01:33:02 2015 +0100 (2015-11-16)
parents c3d539e33710
children
line source
1 --[[--
2 locale.do_with(
3 locale_options, -- table with locale information (as if passed to locale.set(...))
4 function()
5 ... -- code to be executed with the given locale settings
6 end
7 )
9 This function executes code with temporarily changed locale settings. See locale.set(...) for correct usage of 'locale_options'.
11 --]]--
13 function locale.do_with(locale_options, block)
14 local old_data = table.new(locale._current_data)
15 if locale_options.reset then
16 locale._current_data = {}
17 end
18 for key, value in pairs(locale_options) do
19 if key ~= "reset" then
20 locale._current_data[key] = value
21 end
22 end
23 locale.set(locale_options)
24 block()
25 locale._current_data = old_data
26 end

Impressum / About Us