Update lib script for sgettext and sngettext

This commit is contained in:
BrunoMine 2017-07-16 12:42:10 -03:00
parent a5cc2639f2
commit 8f92aed533
1 changed files with 11 additions and 3 deletions

View File

@ -21,11 +21,11 @@ local function format(str, ...)
return (str:gsub("(@?)@(%(?)(%d+)(%)?)", repl))
end
local gettext, ngettext
local gettext, ngettext, sgettext, sngettext
if minetest.get_modpath("intllib") then
if intllib.make_gettext_pair then
-- New method using gettext.
gettext, ngettext = intllib.make_gettext_pair()
gettext, ngettext, sgettext, sngettext = intllib.make_gettext_pair()
else
-- Old method using text files.
gettext = intllib.Getter()
@ -42,4 +42,12 @@ ngettext = ngettext or function(msgid, msgid_plural, n, ...)
return format(n==1 and msgid or msgid_plural, ...)
end
return gettext, ngettext
sgettext = sgettext or function(lang, msgid, ...)
return format(msgid, ...)
end
sngettext = sngettext or function(lang, msgid, msgid_plural, n, ...)
return format(n==1 and msgid or msgid_plural, ...)
end
return gettext, ngettext, sgettext, sngettext