1
0
mirror of https://github.com/minetest-mods/intllib.git synced 2024-11-16 23:40:30 +01:00

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

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