diff options
author | Vanessa Dannenberg <vanessa.e.dannenberg@gmail.com> | 2019-03-10 19:44:56 -0400 |
---|---|---|
committer | Vanessa Dannenberg <vanessa.e.dannenberg@gmail.com> | 2019-03-10 19:44:56 -0400 |
commit | 18fc18b5aece7aae1caafd38a2c742af7974348c (patch) | |
tree | 460b6c6ab31c621cd437d04aa7443e5bb343d718 /maptools/intllib.lua | |
parent | b21c3d368077aa3a1c42ff1582cda6263c018585 (diff) | |
download | dreambuilder_modpack-18fc18b5aece7aae1caafd38a2c742af7974348c.tar dreambuilder_modpack-18fc18b5aece7aae1caafd38a2c742af7974348c.tar.gz dreambuilder_modpack-18fc18b5aece7aae1caafd38a2c742af7974348c.tar.bz2 dreambuilder_modpack-18fc18b5aece7aae1caafd38a2c742af7974348c.tar.xz dreambuilder_modpack-18fc18b5aece7aae1caafd38a2c742af7974348c.zip |
update cottages, digilines, locks, maptools, moreblocks, technic,
and travelnet
Diffstat (limited to 'maptools/intllib.lua')
-rw-r--r-- | maptools/intllib.lua | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/maptools/intllib.lua b/maptools/intllib.lua new file mode 100644 index 0000000..c7af2c2 --- /dev/null +++ b/maptools/intllib.lua @@ -0,0 +1,44 @@ +-- Fallback functions for when `intllib` is not installed. +-- Code released under Unlicense <http://unlicense.org>. + +-- Get the latest version of this file at: +-- https://raw.githubusercontent.com/minetest-mods/intllib/master/lib/intllib.lua + +local function format(str, ...) + local args = { ... } + local function repl(escape, open, num, close) + if escape == "" then + local replacement = tostring(args[tonumber(num)]) + if open == "" then + replacement = replacement..close + end + return replacement + else + return "@"..open..num..close + end + end + return (str:gsub("(@?)@(%(?)(%d+)(%)?)", repl)) +end + +local gettext, ngettext +if minetest.get_modpath("intllib") then + if intllib.make_gettext_pair then + -- New method using gettext. + gettext, ngettext = intllib.make_gettext_pair() + else + -- Old method using text files. + gettext = intllib.Getter() + end +end + +-- Fill in missing functions. + +gettext = gettext or function(msgid, ...) + return format(msgid, ...) +end + +ngettext = ngettext or function(msgid, msgid_plural, n, ...) + return format(n==1 and msgid or msgid_plural, ...) +end + +return gettext, ngettext |