foundryvtt-wh4-lang-fr-fr/tools/parse_template_for_localization.lua

54 lines
1.6 KiB
Lua
Raw Permalink Normal View History

2021-05-08 08:50:48 +02:00
package.path = package.path .. ";luajson/?.lua"
local JSON = require"json"
local lfs = require"lfs"
2021-05-10 19:41:24 +02:00
local pathTab = {
"../../WFRP4e-FoundryVTT/",
"/home/morr/.local/share/FoundryVTT/Data/modules/wfrp4e-core",
"/home/morr/.local/share/FoundryVTT/Data/modules/wfrp4e-eis",
"/home/morr/.local/share/FoundryVTT/Data/modules/wfrp4e-rnhd",
"/home/morr/.local/share/FoundryVTT/Data/modules/wfrp4e-dotr"
}
2021-05-08 08:50:48 +02:00
local frjsonf = "../fr.json"
fp = io.open(frjsonf, "r")
local frtags = JSON.decode( fp:read("*a") )
fp:close()
local function parse_folder( mypath )
--print("*** ENTERING", mypath)
for file in lfs.dir(mypath) do
--print(file)
if file == '.' or file == '..' then
else
if lfs.attributes(mypath.."/"..file).mode == "directory" then
parse_folder(mypath .."/".. file)
else
local fp = io.open(mypath .."/".. file, "r+")
if fp then
local html = fp:read("*a");
-- Template case
for match in html:gmatch( "{{localize \"([%w%.]*)\"") do
--print(match)
if not frtags[match] then
2021-05-10 19:41:24 +02:00
print("MATCH not found !!!", match,mypath .."/".. file)
2021-05-08 08:50:48 +02:00
end
end
-- Template case
2021-05-10 19:41:24 +02:00
for match in html:gmatch( "game.i18n.localize%(%s*\"([%w%.%d%-]*)\"") do -- .localize(%s*"
2021-05-08 08:50:48 +02:00
--print(match)
if not frtags[match] then
2021-05-10 19:41:24 +02:00
print("MATCH not found !!!", match, mypath .."/".. file)
2021-05-08 08:50:48 +02:00
end
end
fp:close()
end
end
end
end
end
2021-05-10 19:41:24 +02:00
for _, path in pairs(pathTab) do
parse_folder( path )
end