XML Handler: Include missing language macros.
This commit is contained in:
parent
06e4d78e5d
commit
cad0b090b6
|
|
@ -141,6 +141,38 @@
|
|||
table.insert(xml, [[ </input>]]);
|
||||
table.insert(xml, [[ </macro>]]);;
|
||||
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, "<include>", '');
|
||||
xml_file_content = string.gsub(xml_file_content, "</include>", '');
|
||||
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, [[ </macros>]]);
|
||||
table.insert(xml, [[ </phrases>]]);
|
||||
|
|
@ -148,7 +180,7 @@
|
|||
table.insert(xml, [[ </section>]]);
|
||||
table.insert(xml, [[</document>]]);
|
||||
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();
|
||||
|
|
|
|||
Loading…
Reference in New Issue