webmcp

view framework/env/locale/do_with.lua @ 401:ad437022be90

Quick fix to avoid problems on document creation
author jbe
date Mon Jan 04 00:48:47 2016 +0100 (2016-01-04)
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