Return nil if `msgstr` is empty.

Also remove debugging statements left from previous commit.
This commit is contained in:
Diego Martínez 2017-01-24 20:10:37 -03:00
parent 50c42165ea
commit a3f9090ee8
2 changed files with 5 additions and 6 deletions

View File

@ -249,7 +249,6 @@ local function load_catalog(filename)
err = nil err = nil
local hdrs = data[""] local hdrs = data[""]
if not (hdrs and hdrs[0]) then if not (hdrs and hdrs[0]) then
print(dump(hdrs))
return bail("catalog has no headers") return bail("catalog has no headers")
end end

View File

@ -77,8 +77,9 @@ local gettext = dofile(minetest.get_modpath("intllib").."/gettext.lua")
local function catgettext(catalogs, msgid) local function catgettext(catalogs, msgid)
for _, cat in ipairs(catalogs) do for _, cat in ipairs(catalogs) do
local msgstr = cat and cat[msgid] local msgstr = cat and cat[msgid]
if msgstr then if msgstr and msgstr~="" then
return msgstr[0] local msg = msgstr[0]
return msg~="" and msg or nil
end end
end end
end end
@ -86,12 +87,11 @@ end
local function catngettext(catalogs, msgid, msgid_plural, n) local function catngettext(catalogs, msgid, msgid_plural, n)
n = math.floor(n) n = math.floor(n)
for i, cat in ipairs(catalogs) do for i, cat in ipairs(catalogs) do
print(i, dump(cat))
local msgstr = cat and cat[msgid] local msgstr = cat and cat[msgid]
if msgstr then if msgstr then
local index = cat.plural_index(n) local index = cat.plural_index(n)
print("catngettext:", index, msgstr[index]) local msg = msgstr[index]
return msgstr[index] return msg~="" and msg or nil
end end
end end
return n==1 and msgid or msgid_plural return n==1 and msgid or msgid_plural