webmcp

view framework/env/locale/do_with.lua @ 0:9fdfb27f8e67

Version 1.0.0
author jbe/bsw
date Sun Oct 25 12:00:00 2009 +0100 (2009-10-25)
parents
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