aboutsummaryrefslogtreecommitdiff
path: root/advtrains/locale/update-l10n.lua
diff options
context:
space:
mode:
Diffstat (limited to 'advtrains/locale/update-l10n.lua')
-rw-r--r--advtrains/locale/update-l10n.lua41
1 files changed, 41 insertions, 0 deletions
diff --git a/advtrains/locale/update-l10n.lua b/advtrains/locale/update-l10n.lua
new file mode 100644
index 0000000..e0c2418
--- /dev/null
+++ b/advtrains/locale/update-l10n.lua
@@ -0,0 +1,41 @@
+local tf = {}
+for l in io.lines() do
+ tf[#tf+1] = l
+end
+
+local ot = {[0] = ""}
+local f = io.open("template.txt") or error("Cannot open translation template")
+for l in f:lines() do
+ if l == "" then -- blank line
+ if ot[#ot] ~= l then ot[#ot+1] = l end
+ elseif l:find("^#") then -- comment
+ if ot[#ot] ~= l then ot[#ot+1] = l end
+ else
+ s = l:match("^(.+[^@]=)")
+ if s then
+ local found = false
+ for i = 1, #tf, 1 do
+ if tf[i]:find(s, 1, true) == 1 then
+ found = i
+ break
+ end
+ end
+ if found then
+ local fc = found-1
+ while fc > 0 do
+ if not tf[fc]:find("^#") then break end
+ fc = fc-1
+ end
+ for i = fc+1, found, 1 do
+ if ot[#ot] ~= tf[i] then ot[#ot+1] = tf[i] end
+ end
+ else
+ if ot[#ot] ~= l then ot[#ot+1] = l end
+ end
+ end
+ end
+end
+
+for i = 1, #ot, 1 do
+ print(ot[i])
+end \ No newline at end of file