From cad0b090b65c3319c7b3953e54cdc936e9a4c189 Mon Sep 17 00:00:00 2001 From: Nate Jones Date: Thu, 30 Apr 2015 06:59:24 +0000 Subject: [PATCH] XML Handler: Include missing language macros. --- .../resources/scripts/languages/languages.lua | 34 ++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/resources/install/scripts/app/xml_handler/resources/scripts/languages/languages.lua b/resources/install/scripts/app/xml_handler/resources/scripts/languages/languages.lua index 01d6a776a9..e9c9ba8a93 100644 --- a/resources/install/scripts/app/xml_handler/resources/scripts/languages/languages.lua +++ b/resources/install/scripts/app/xml_handler/resources/scripts/languages/languages.lua @@ -141,6 +141,38 @@ table.insert(xml, [[ ]]); table.insert(xml, [[ ]]);; end + + --read root xml language file, parse included xml files + local xml_file_paths = {} + local file_handle = io.open("/usr/local/freeswitch/conf/lang/"..language.."/"..language..".xml", "r"); + if (file_handle ~= nil) then + for file_line in file_handle:lines() do + if (string.find(file_line, 'cmd="include" data="', 0, true) ~= nil) then + pos_beg = string.find(file_line, 'cmd="include" data="', 0, true) + 20; + pos_end = string.find(file_line, '"/>', 0, true) - 1; + xml_file_path = string.sub(file_line, pos_beg, pos_end); + table.insert(xml_file_paths, "/usr/local/freeswitch/conf/lang/"..language.."/"..xml_file_path); + --freeswitch.consoleLog("notice", "file path = "..xml_file_path.."\n"); + end + end + end + file_handle:close(); + + --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 + xml_file = io.open(xml_file_path, "r"); + if (xml_file ~= nil) then + xml_file_content = xml_file:read("*a"); + xml_file_content = string.gsub(xml_file_content, "", ''); + xml_file_content = string.gsub(xml_file_content, "", ''); + table.insert(xml, xml_file_content); + --freeswitch.consoleLog("notice", "file contents...\n\n"..xml_file_content.."\n"); + end + xml_file:close(); + end + end + --output xml & close previous file table.insert(xml, [[ ]]); table.insert(xml, [[ ]]); @@ -148,7 +180,7 @@ table.insert(xml, [[ ]]); table.insert(xml, [[]]); XML_STRING = table.concat(xml, "\n"); - freeswitch.consoleLog("notice", "[xml_handler] language " .. XML_STRING .. " \n") + --freeswitch.consoleLog("notice", "[xml_handler] language " .. XML_STRING .. " \n") --close the database connection dbh:release();