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.lua15
1 files changed, 10 insertions, 5 deletions
diff --git a/advtrains/locale/update-l10n.lua b/advtrains/locale/update-l10n.lua
index e0c2418..011f9c6 100644
--- a/advtrains/locale/update-l10n.lua
+++ b/advtrains/locale/update-l10n.lua
@@ -1,10 +1,14 @@
+local lang = arg[1] or error("No language supplied")
+local tfn = string.format("advtrains.%s.tr", lang)
+local f = io.open(tfn, "rb") or error("Cannot read from translation file")
local tf = {}
-for l in io.lines() do
+for l in f:lines() do
tf[#tf+1] = l
end
+f:close()
local ot = {[0] = ""}
-local f = io.open("template.txt") or error("Cannot open translation template")
+local f = io.open("template.txt", "rb") or error("Cannot read from translation template")
for l in f:lines() do
if l == "" then -- blank line
if ot[#ot] ~= l then ot[#ot+1] = l end
@@ -35,7 +39,8 @@ for l in f:lines() do
end
end
end
+f:close()
-for i = 1, #ot, 1 do
- print(ot[i])
-end \ No newline at end of file
+local f = io.open(tfn, "wb") or error("Cannot write to translation file")
+f:write(table.concat(ot,"\n"))
+f:close() \ No newline at end of file