Add 0.4 compability layer (translator)

master
Wuzzy 2020-09-08 20:05:11 +02:00
parent a3538225f8
commit e1baf9c2c0
1 changed files with 27 additions and 1 deletions

View File

@ -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
teleports = {}