forked from WoW-MogIt/MogIt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
LocaleExtractor.lua
39 lines (36 loc) · 942 Bytes
/
LocaleExtractor.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
local strings;
local output;
function getStrings(name)
output = output.."\n\n\t--[[ "..name.." ]]--";
local file = io.open(name,"r"):read("*all");
for str in file:gmatch("L%[\"(.-[^\\])\"%]") do
if not strings[str] then
output = output.."\nL[\""..str.."\"] = true"
strings[str] = true;
end
end
if name:match(".xml$") then
local dir = name:match("^(.+\\).-%.xml$");
for lua in file:gmatch("<%s*Script %s*file%s*=%s*\"(.-%.lua)\"%s*/>") do
getStrings(dir..lua);
end
for xml in file:gmatch("<%s*Include %s*file%s*=%s*\"(.-%.xml)\"%s*/>") do
getStrings(dir..xml);
end
end
end
function getLocale(file,files)
strings = {};
--output = "L[\"Transmogrification Assistant\"] = true";
output = "";
for k,v in ipairs(files) do
output = output.."\n\n";
getStrings(v);
end
local list = io.open(file..".lua","w");
list:write(output);
end
getLocale("LocaleList",{
"Core\\Core.xml",
"Modules\\Modules.xml",
});