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

45 lines
1.2 KiB
Lua
Raw 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"
local path = "../../WFRP4e-FoundryVTT/"
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
print("MATCH not found !!!", match)
end
end
-- Template case
for match in html:gmatch( "game.i18n.localize%(%s*\"([%w%.]*)\"") do -- .localize(%s*"
--print(match)
if not frtags[match] then
print("MATCH not found !!!", match)
end
end
fp:close()
end
end
end
end
end
parse_folder( path )