webmcp
changeset 564:6141ab127861
Fixed handling of derived translation tables
author | jbe |
---|---|
date | Sun Mar 07 17:21:12 2021 +0100 (2021-03-07) |
parents | 2c31275322db |
children | 4e5d8d6c0d7c |
files | framework/bin/langtool.lua |
line diff
1.1 --- a/framework/bin/langtool.lua Sun Mar 07 16:58:59 2021 +0100 1.2 +++ b/framework/bin/langtool.lua Sun Mar 07 17:21:12 2021 +0100 1.3 @@ -122,13 +122,10 @@ 1.4 end 1.5 end 1.6 1.7 -local function update_translation(key, value) 1.8 - if translations[key] ~= nil or #directories == 0 or key == "__parent" then 1.9 - translations[key] = value 1.10 - end 1.11 -end 1.12 +local updates 1.13 1.14 if in_filetype == "po" then 1.15 + updates = {} 1.16 io.stderr:write('Reading translations from po file "', in_filename, '".\n') 1.17 local next_line = io.lines(in_filename) 1.18 for line in next_line do 1.19 @@ -144,7 +141,7 @@ 1.20 error("Duplicate key '" .. key .. "' in po file.") 1.21 end 1.22 if value == "" then value = false end 1.23 - update_translation(key, value) 1.24 + updates[key] = value 1.25 end 1.26 end 1.27 elseif in_filetype == "lua" then 1.28 @@ -156,9 +153,21 @@ 1.29 func = assert(loadfile(in_filename)) 1.30 setfenv(func, {}) 1.31 end 1.32 - local updates = func() 1.33 + updates = func() 1.34 +end 1.35 + 1.36 +if updates.__parent then 1.37 + for key in pairs(updates) do 1.38 + if translations[key] == nil and key ~= "__parent" then 1.39 + updates[key] = nil 1.40 + end 1.41 + end 1.42 + translations = updates 1.43 +else 1.44 for key, value in pairs(updates) do 1.45 - update_translation(key, value) 1.46 + if translations[key] ~= nil or #directories == 0 then 1.47 + translations[key] = value 1.48 + end 1.49 end 1.50 end 1.51