2 -- Fallback functions for when `intllib` is not installed.
3 -- Code released under Unlicense <http://unlicense.org>.
5 -- Get the latest version of this file at:
6 -- https://raw.githubusercontent.com/minetest-mods/intllib/master/lib/intllib.lua
8 local function format(str
, ...)
10 local function repl(escape
, open
, num
, close
)
12 local replacement
= tostring(args
[tonumber(num
)])
14 replacement
= replacement
..close
18 return "@"..open
..num
..close
21 return (str
:gsub("(@?)@(%(?)(%d+)(%)?)", repl
))
24 local gettext
, ngettext
25 if minetest
.get_modpath("intllib") then
26 if intllib
.make_gettext_pair
then
27 -- New method using gettext.
28 gettext
, ngettext
= intllib
.make_gettext_pair()
30 -- Old method using text files.
31 gettext
= intllib
.Getter()
35 -- Fill in missing functions.
37 gettext
= gettext
or function(msgid
, ...)
38 return format(msgid
, ...)
41 ngettext
= ngettext
or function(msgid
, msgid_plural
, n
, ...)
42 return format(n
==1 and msgid
or msgid_plural
, ...)
45 return gettext
, ngettext