From 15a056de432944815c5389e0ec544b993d3f3d40 Mon Sep 17 00:00:00 2001 From: ywang Date: Sun, 28 Mar 2021 13:02:16 +0200 Subject: Make update-l10n.lua edit in place; use Sie-form for German translations --- advtrains/locale/update-l10n.lua | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'advtrains/locale/update-l10n.lua') 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 -- cgit v1.2.3