webmcp

view framework/env/locale/do_with.lua @ 88:c743d80859cf

Added tag v1.2.4 for changeset a5106c0a9be4
author jbe
date Fri Jul 06 12:54:26 2012 +0200 (2012-07-06)
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