diff --git a/.luacheckrc b/.luacheckrc index 529088b..d8093fc 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -23,7 +23,7 @@ read_globals = { "nodecore", -- Other mods - "stairsplus", "toolranks", + "stairsplus", "toolranks", "gettext", "intllib", } exclude_files = { diff --git a/depends.txt b/depends.txt index e422c15..fc85800 100644 --- a/depends.txt +++ b/depends.txt @@ -6,6 +6,7 @@ mobs_monster? 3d_armor? toolranks? moreblocks? +intllib? vessels? nc_fire? mcl_armor? diff --git a/init.lua b/init.lua index 482dab9..49aa9c5 100644 --- a/init.lua +++ b/init.lua @@ -1,15 +1,41 @@ lavastuff = {} -local MODPATH = minetest.get_modpath("lavastuff") +local MODNAME = minetest.get_current_modname() +local MODPATH = minetest.get_modpath(MODNAME) local COOLDOWN = dofile(MODPATH.."/cooldowns.lua") local S if minetest.get_translator ~= nil then - S = minetest.get_translator(minetest.get_current_modname()) + S = minetest.get_translator(MODNAME) else - S = function(str) - return(str) + if minetest.get_modpath("intllib") then + dofile(minetest.get_modpath("intllib").."/init.lua") + 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 + S = gettext + else + -- mock the translator function for MT 0.4 + function minetest.translate(textdomain, str, ...) + local arg = {n=select('#', ...), ...} + return str:gsub("@(.)", function(matched) + local c = string.byte(matched) + if string.byte("1") <= c and c <= string.byte("9") then + return arg[c - string.byte("0")] + else + return matched + end + end) + end + function minetest.get_translator(textdomain) + return function(str, ...) return minetest.translate(textdomain or "", str, ...) end + end + S = minetest.get_translator(MODNAME) end end @@ -524,4 +550,4 @@ else end end -minetest.log("action", "[lavastuff]: Mod Loaded!") \ No newline at end of file +minetest.log("action", "[lavastuff]: Mod Loaded!")