# HG changeset patch # User jbe # Date 1615134072 -3600 # Node ID 6141ab127861ce16ee3e56c1c44b31aca69b7f5c # Parent 2c31275322dba132d8a6065a76f8569236eaa04e Fixed handling of derived translation tables diff -r 2c31275322db -r 6141ab127861 framework/bin/langtool.lua --- a/framework/bin/langtool.lua Sun Mar 07 16:58:59 2021 +0100 +++ b/framework/bin/langtool.lua Sun Mar 07 17:21:12 2021 +0100 @@ -122,13 +122,10 @@ end end -local function update_translation(key, value) - if translations[key] ~= nil or #directories == 0 or key == "__parent" then - translations[key] = value - end -end +local updates if in_filetype == "po" then + updates = {} io.stderr:write('Reading translations from po file "', in_filename, '".\n') local next_line = io.lines(in_filename) for line in next_line do @@ -144,7 +141,7 @@ error("Duplicate key '" .. key .. "' in po file.") end if value == "" then value = false end - update_translation(key, value) + updates[key] = value end end elseif in_filetype == "lua" then @@ -156,9 +153,21 @@ func = assert(loadfile(in_filename)) setfenv(func, {}) end - local updates = func() + updates = func() +end + +if updates.__parent then + for key in pairs(updates) do + if translations[key] == nil and key ~= "__parent" then + updates[key] = nil + end + end + translations = updates +else for key, value in pairs(updates) do - update_translation(key, value) + if translations[key] ~= nil or #directories == 0 then + translations[key] = value + end end end