Handle the phrases_dir nil in a more flexible way.

This commit is contained in:
markjcrane 2016-03-04 15:51:10 -07:00
parent 7cbb32dcd3
commit 010a237c09
1 changed files with 32 additions and 37 deletions

View File

@ -34,14 +34,6 @@
--action = params:getHeader("action");
language = params:getHeader("lang");
--make sure phrase_dir variable is not nil
if (phrases_dir == nil) then
--define the variable
phrases_dir = '';
--include the config.lua and local.lua
require "resources.functions.config";
end
--additional information
--event_calling_function = params:getHeader("Event-Calling-Function");
@ -150,6 +142,9 @@
table.insert(xml, [[ </macro>]]);
end
--if nil do nt include language xml from the file system the phrases directory is not set in default settings - category: switch name: phrases_dir or its false
--it also can be nil if config.lua is not writable so that it can be defined in it
if (phrases_dir == nil) then
--read root xml language file, parse included xml files
local xml_file_paths = {}
local file_handle = io.open(phrases_dir.."/"..language.."/"..language..".xml", "r");
@ -165,7 +160,6 @@
end
file_handle:close();
end
--iterate array of file paths, get contents of other xml macro files
for key, xml_file_path in pairs(xml_file_paths) do
if (file_exists(xml_file_path)) then
@ -180,6 +174,7 @@
xml_file:close();
end
end
end
--output xml & close previous file
table.insert(xml, [[ </macros>]]);