summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDiego Martínez <kaeza@users.noreply.github.com>2017-01-24 20:10:37 -0300
committerDiego Martínez <kaeza@users.noreply.github.com>2017-01-24 20:10:37 -0300
commita3f9090ee8f30001f355c68c634682959f5ebe55 (patch)
tree783ed114f61825b115fcc92303e8a3ed516d9449
parent50c42165ea1ef8592fcc8b2948201a52a6f7c82e (diff)
Return nil if `msgstr` is empty.
Also remove debugging statements left from previous commit.
-rw-r--r--gettext.lua1
-rw-r--r--init.lua10
2 files changed, 5 insertions, 6 deletions
diff --git a/gettext.lua b/gettext.lua
index 6f3a1cb..d6ce223 100644
--- a/gettext.lua
+++ b/gettext.lua
@@ -249,7 +249,6 @@ local function load_catalog(filename)
err = nil
local hdrs = data[""]
if not (hdrs and hdrs[0]) then
- print(dump(hdrs))
return bail("catalog has no headers")
end
diff --git a/init.lua b/init.lua
index ee6d1a9..497b725 100644
--- a/init.lua
+++ b/init.lua
@@ -77,8 +77,9 @@ local gettext = dofile(minetest.get_modpath("intllib").."/gettext.lua")
local function catgettext(catalogs, msgid)
for _, cat in ipairs(catalogs) do
local msgstr = cat and cat[msgid]
- if msgstr then
- return msgstr[0]
+ if msgstr and msgstr~="" then
+ local msg = msgstr[0]
+ return msg~="" and msg or nil
end
end
end
@@ -86,12 +87,11 @@ end
local function catngettext(catalogs, msgid, msgid_plural, n)
n = math.floor(n)
for i, cat in ipairs(catalogs) do
- print(i, dump(cat))
local msgstr = cat and cat[msgid]
if msgstr then
local index = cat.plural_index(n)
- print("catngettext:", index, msgstr[index])
- return msgstr[index]
+ local msg = msgstr[index]
+ return msg~="" and msg or nil
end
end
return n==1 and msgid or msgid_plural