webmcp

view framework/env/locale/do_with.lua @ 148:5354d836e6fb

Minor bugfix in json_newindex function of JSON library (should return nothing)
author jbe
date Wed Jul 30 22:32:33 2014 +0200 (2014-07-30)
parents 9fdfb27f8e67
children c3d539e33710
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 = {}
15 for key, value in pairs(locale._current_data) do
16 old_data[key] = value
17 end
18 locale.set(locale_options)
19 block()
20 old_data.reset = true
21 locale.set(old_data)
22 end

Impressum / About Us