Add 0.4 compability layer (translator)
parent
a3538225f8
commit
e1baf9c2c0
28
init.lua
28
init.lua
|
@ -1,4 +1,30 @@
|
||||||
local S = minetest.get_translator("teleports")
|
local S
|
||||||
|
if minetest.translate then
|
||||||
|
S = minetest.get_translator("teleports")
|
||||||
|
else
|
||||||
|
-- Compability translator code to support MT 0.4, which doesn't support
|
||||||
|
-- translations for mods.
|
||||||
|
|
||||||
|
local function 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
|
||||||
|
|
||||||
|
S = function(textdomain)
|
||||||
|
return function(str, ...)
|
||||||
|
return translate(textdomain or "", str, ...)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
local F = minetest.formspec_escape
|
local F = minetest.formspec_escape
|
||||||
|
|
||||||
teleports = {}
|
teleports = {}
|
||||||
|
|
Loading…
Reference in New Issue