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

54 lines
1.6 KiB
Lua
Raw Normal View History

2020-05-31 10:10:58 +02:00
package.path = package.path .. ";luajson/?.lua"
local JSON = require"json"
2022-07-20 21:11:32 +02:00
--local enjsonf = "/home/morr/foundry/foundrydata-dev/Data/modules/wfrp4e-dotr/lang/en.json"
2023-01-20 10:05:36 +01:00
--local enjsonf = "/home/morr/foundry/foundrydata-dev/Data/modules/wfrp4e-core/lang/en.json"
--local enjsonf = "/home/morr/foundry/foundrydata-dev/Data/modules/wfrp4e-middenheim/lang/en.json"
--local enjsonf = "/home/morr/foundry/foundrydata-dev/Data/modules/wfrp4e-eis/lang/en.json"
--local enjsonf = "/home/morr/foundry/foundrydata-dev/Data/modules/wfrp4e-rnhd/lang/en.json"
--local enjsonf = "/home/morr/foundry/foundrydata-dev/Data/modules/wfrp4e-up-in-arms/lang/en.json"
2022-09-01 08:23:29 +02:00
local enjsonf = "../../WFRP4e-FoundryVTT/static/lang/en.json"
2020-05-31 10:10:58 +02:00
local frjsonf = "../fr.json"
local fp = io.open(enjsonf, "r")
local entags = JSON.decode( fp:read("*a") )
fp:close()
fp = io.open(frjsonf, "r")
local frtags = JSON.decode( fp:read("*a") )
fp:close()
2021-11-08 21:29:05 +01:00
local todisplay = {}
2020-05-31 10:10:58 +02:00
for tag, value in pairs(entags) do
if not frtags[tag] then
2021-11-08 21:29:05 +01:00
todisplay[#todisplay+1] = { tag=tag, value=value }
2020-05-31 10:10:58 +02:00
end
end
2021-11-08 21:29:05 +01:00
table.sort(todisplay, function (a, b)
return a.tag < b.tag
end
)
2024-09-05 17:26:05 +02:00
2021-11-08 21:29:05 +01:00
for _, tagDef in pairs(todisplay) do
2024-09-05 17:26:05 +02:00
if type(tagDef.value) == "table" then
print('"'.. tagDef.tag ..'":{')
for k, v in pairs(tagDef.value) do
if type(v) == "table" then
print('"'.. k ..'":{')
for kk, vv in pairs(v) do
print('"'.. kk ..'":"'.. vv..'",')
end
print('},')
else
print('"'.. k ..'":"'.. v..'",')
end
end
print('},')
else
print('"'.. tagDef.tag ..'":"'.. tagDef.value..'",')
end
2021-11-08 21:29:05 +01:00
end
2020-05-31 10:10:58 +02:00