backuarg compat with 0.4, intllib vs get_translator

main
mckaygerhard 2023-01-07 16:12:31 -04:00
parent f099d7658b
commit be5366331a
1 changed files with 22 additions and 2 deletions

View File

@ -1,6 +1,26 @@
-- support for i18n
local S = minetest.get_translator(minetest.get_current_modname())
-- Intllib
local S
if minetest.get_translator ~= nil then
S = minetest.get_translator("ethereal") -- 5.x translation function
else
if minetest.get_modpath("intllib") then
dofile(minetest.get_modpath("intllib") .. "/init.lua")
if intllib.make_gettext_pair then
gettext, ngettext = intllib.make_gettext_pair() -- new gettext method
else
gettext = intllib.Getter() -- old text file method
end
S = gettext
else -- boilerplate function
S = function(str, ...)
local args = {...}
return str:gsub("@%d+", function(match)
return args[tonumber(match:sub(2))]
end)
end
end
end
if minetest.global_exists("armor") and armor.elements then
table.insert(armor.elements, "hands")