2 次代碼提交 b4bcbe0192 ... 49b879daf8

作者 SHA1 備註 提交日期
  tenplus1 49b879daf8 update translation checks 2 年之前
  tenplus1 b16371a684 fix intllib return 3 年之前
共有 5 個文件被更改,包括 27 次插入9 次删除
  1. 1 1
      igor.lua
  2. 24 4
      init.lua
  3. 0 2
      intllib.lua
  4. 1 1
      npc.lua
  5. 1 1
      trader.lua

+ 1 - 1
igor.lua

@@ -1,5 +1,5 @@
 
-local S = mobs.intllib
+local S = mobs.intllib_npc
 
 -- Igor by TenPlus1
 

+ 24 - 4
init.lua

@@ -1,11 +1,30 @@
 
 local path = minetest.get_modpath(minetest.get_current_modname()) .. "/"
 
-local S = minetest.get_translator and minetest.get_translator("mobs_npc") or
-		dofile(path .. "intllib.lua")
+-- Check for translation method
+local S
+if minetest.get_translator ~= nil then
+	S = minetest.get_translator("mobs_npc") -- 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
 
-mobs.intllib = S
+mobs.intllib_npc = S
 
 
 -- Check for custom mob spawn file
@@ -34,4 +53,4 @@ end
 dofile(path .. "/lucky_block.lua")
 
 
-print (S("[MOD] Mobs Redo NPCs loaded"))
+print ("[MOD] Mobs Redo NPCs loaded")

+ 0 - 2
intllib.lua

@@ -1,3 +0,0 @@
-dofile(minetest.get_modpath("intllib").."/init.lua")
-

+ 1 - 1
npc.lua

@@ -1,5 +1,5 @@
 
-local S = mobs.intllib
+local S = mobs.intllib_npc
 
 -- Npc by TenPlus1
 

+ 1 - 1
trader.lua

@@ -1,5 +1,5 @@
 
-local S = mobs.intllib
+local S = mobs.intllib_npc
 
 -- define table containing names for use and shop items for sale