added intllib support (en/de)

This commit is contained in:
TenPlus1 2016-06-11 09:47:43 +01:00
parent 093b8c9eed
commit db7e02af1a
6 changed files with 131 additions and 29 deletions

53
api.lua
View File

@ -4,8 +4,29 @@
mobs = {} mobs = {}
mobs.mod = "redo" mobs.mod = "redo"
-- Invisibility mod -- Intllib
local S
if minetest.get_modpath("intllib") then
S = intllib.Getter()
else
S = function(s, a, ...)
if a == nil then
return s
end
a = {a, ...}
return s:gsub("(@?)@(%(?)(%d+)(%)?)",
function(e, o, n, c)
if e == "" then
return a[tonumber(n)] .. (o == "" and c or "")
else
return "@" .. o .. n .. c
end
end)
end
end
mobs.intllib = S
-- Invisibility mod
local invisibility = invisibility or {} local invisibility = invisibility or {}
-- Load settings -- Load settings
@ -1769,7 +1790,7 @@ local mob_punch = function(self, hitter, tflp, tool_capabilities, dir)
-- error checking when mod profiling is enabled -- error checking when mod profiling is enabled
if not tool_capabilities then if not tool_capabilities then
print ("[MOBS] mod profiling enabled, damage not enabled") print (S("[MOBS] mod profiling enabled, damage not enabled"))
return return
end end
@ -2079,7 +2100,7 @@ local mob_step = function(self, dtime)
end end
minetest.log("action", minetest.log("action",
"lifetimer expired, removed " .. self.name) S("lifetimer expired, removed @1", self.name))
effect(pos, 15, "tnt_smoke.png") effect(pos, 15, "tnt_smoke.png")
@ -2336,13 +2357,13 @@ function mobs:spawn_specific(name, nodes, neighbors, min_light, max_light,
if new_chance ~= nil then if new_chance ~= nil then
if new_chance == 0 then if new_chance == 0 then
print("[Mobs Redo] " .. name .. " has spawning disabled") print(S("[Mobs Redo] @1 has spawning disabled", name))
return return
end end
chance = new_chance chance = new_chance
print ("[Mobs Redo] Chance setting for " .. name .. " changed to " .. chance) print (S("[Mobs Redo] Chance setting for @1 changed to @2", name, chance))
end end
@ -2430,8 +2451,8 @@ function mobs:spawn_specific(name, nodes, neighbors, min_light, max_light,
-- .. minetest.pos_to_string(pos) .. " on " -- .. minetest.pos_to_string(pos) .. " on "
-- .. node.name .. " near " .. neighbors[1]) -- .. node.name .. " near " .. neighbors[1])
else else
print ("[mobs]" .. name .. " failed to spawn at " print (S("[mobs] @1 failed to spawn at @2",
.. minetest.pos_to_string(pos)) name, minetest.pos_to_string(pos)))
end end
end end
@ -2711,7 +2732,7 @@ function mobs:capture_mob(self, clicker, chance_hand, chance_net, chance_lasso,
if self.tamed == false if self.tamed == false
and force_take == false then and force_take == false then
minetest.chat_send_player(name, "Not tamed!") minetest.chat_send_player(name, S("Not tamed!"))
return return
end end
@ -2720,7 +2741,7 @@ function mobs:capture_mob(self, clicker, chance_hand, chance_net, chance_lasso,
if self.owner ~= name if self.owner ~= name
and force_take == false then and force_take == false then
minetest.chat_send_player(name, self.owner.." is owner!") minetest.chat_send_player(name, S("@1 is owner!", self.owner))
return return
end end
@ -2761,7 +2782,7 @@ function mobs:capture_mob(self, clicker, chance_hand, chance_net, chance_lasso,
self.object:remove() self.object:remove()
else else
minetest.chat_send_player(name, "Missed!") minetest.chat_send_player(name, S("Missed!"))
end end
end end
end end
@ -2800,8 +2821,8 @@ function mobs:feed_tame(self, clicker, feed_count, breed, tame)
if self.htimer < 1 then if self.htimer < 1 then
minetest.chat_send_player(clicker:get_player_name(), minetest.chat_send_player(clicker:get_player_name(),
self.name:split(":")[2] S("@1 at full health (@2)",
.. " at full health (" .. tostring(self.health) .. ")") self.name:split(":")[2], tostring(self.health)))
self.htimer = 5 self.htimer = 5
end end
@ -2835,8 +2856,8 @@ function mobs:feed_tame(self, clicker, feed_count, breed, tame)
if self.tamed == false then if self.tamed == false then
minetest.chat_send_player(clicker:get_player_name(), minetest.chat_send_player(clicker:get_player_name(),
self.name:split(":")[2] S("@1 has been tamed!",
.. " has been tamed!") self.name:split(":")[2]))
end end
self.tamed = true self.tamed = true
@ -2876,8 +2897,8 @@ function mobs:feed_tame(self, clicker, feed_count, breed, tame)
minetest.show_formspec(name, "mobs_nametag", "size[8,4]" minetest.show_formspec(name, "mobs_nametag", "size[8,4]"
.. default.gui_bg .. default.gui_bg
.. default.gui_bg_img .. default.gui_bg_img
.. "field[0.5,1;7.5,0;name;Enter name:;" .. tag .. "]" .. "field[0.5,1;7.5,0;name;" .. S("Enter name:") .. ";" .. tag .. "]"
.. "button_exit[2.5,3.5;3,1;mob_rename;Rename]") .. "button_exit[2.5,3.5;3,1;mob_rename;" .. S("Rename") .. "]")
end end

View File

@ -1,7 +1,9 @@
local S = mobs.intllib
-- name tag -- name tag
minetest.register_craftitem("mobs:nametag", { minetest.register_craftitem("mobs:nametag", {
description = "Nametag", description = S("Nametag"),
inventory_image = "mobs_nametag.png", inventory_image = "mobs_nametag.png",
}) })
@ -13,20 +15,20 @@ core.register_craft({
-- leather -- leather
minetest.register_craftitem("mobs:leather", { minetest.register_craftitem("mobs:leather", {
description = "Leather", description = S("Leather"),
inventory_image = "mobs_leather.png", inventory_image = "mobs_leather.png",
}) })
-- raw meat -- raw meat
minetest.register_craftitem("mobs:meat_raw", { minetest.register_craftitem("mobs:meat_raw", {
description = "Raw Meat", description = S("Raw Meat"),
inventory_image = "mobs_meat_raw.png", inventory_image = "mobs_meat_raw.png",
on_use = minetest.item_eat(3), on_use = minetest.item_eat(3),
}) })
-- cooked meat -- cooked meat
minetest.register_craftitem("mobs:meat", { minetest.register_craftitem("mobs:meat", {
description = "Meat", description = S("Meat"),
inventory_image = "mobs_meat.png", inventory_image = "mobs_meat.png",
on_use = minetest.item_eat(8), on_use = minetest.item_eat(8),
}) })
@ -40,7 +42,7 @@ minetest.register_craft({
-- golden lasso -- golden lasso
minetest.register_tool("mobs:magic_lasso", { minetest.register_tool("mobs:magic_lasso", {
description = "Magic Lasso (right-click animal to put in inventory)", description = S("Magic Lasso (right-click animal to put in inventory)"),
inventory_image = "mobs_magic_lasso.png", inventory_image = "mobs_magic_lasso.png",
}) })
@ -55,7 +57,7 @@ minetest.register_craft({
-- net -- net
minetest.register_tool("mobs:net", { minetest.register_tool("mobs:net", {
description = "Net (right-click animal to put in inventory)", description = S("Net (right-click animal to put in inventory)"),
inventory_image = "mobs_net.png", inventory_image = "mobs_net.png",
}) })
@ -70,7 +72,7 @@ minetest.register_craft({
-- shears (right click to shear animal) -- shears (right click to shear animal)
minetest.register_tool("mobs:shears", { minetest.register_tool("mobs:shears", {
description = "Steel Shears (right-click to shear)", description = S("Steel Shears (right-click to shear)"),
inventory_image = "mobs_shears.png", inventory_image = "mobs_shears.png",
}) })

View File

@ -1,2 +1,3 @@
default default
invisibility? invisibility?
intllib?

38
locale/de.txt Normal file
View File

@ -0,0 +1,38 @@
# German Translation for mobs_redo mod
# Deutsche Übersetzung der mobs_redo Mod
# last update: 2016/June/10
# Author: Xanthin
#init.lua
[MOD] Mobs Redo loaded = [MOD] Mobs Redo geladen
#api.lua
[MOBS] mod profiling enabled, damage not enabled = [MOBS] Modanalyse aktiviert, Schaden deaktiviert
lifetimer expired, removed @1 = Lebensdauer abgelaufen, @1 wurde entfernt
[Mobs Redo] @1 has spawning disabled = [Mobs Redo] Spawnen von @1 ist deaktiviert
[Mobs Redo] Chance setting for @1 is now @2 = [Mobs Redo] Wahrscheinlichkeitswert für @1 ist jetzt @2
[mobs] @1 failed to spawn at @2 = [mobs] @1 konnte nicht bei @2 spawnen
Not tamed! = Nicht gezähmt!
@1 is owner! = @1 ist Besitzer!
Missed! = Verfehlt!
@1 at full health (@2) = @1 bei voller Gesundheit (@2)
@1 has been tamed! = @1 ist gezähmt worden!
Enter name: = Namen eingeben:
Rename = Umbenennen
#crafts.lua
Nametag = Namensschild
Leather = Leder
Raw Meat = Rohes Fleisch
Meat = Fleisch
Magic Lasso (right-click animal to put in inventory) = Magisches Lasso (Rechtsklick auf Tier,\num es ins Inventar zu legen)
Net (right-click animal to put in inventory) = Netz (Rechtsklick auf Tier,\num es ins Inventar zu legen)
Steel Shears (right-click to shear) = Stahlschere (Rechtsklick zum Scheren)
#spawner.lua
Mob Spawner = Mobspawner
Mob MinLight MaxLight Amount PlayerDist = Mob MinLicht MaxLicht Menge SpielerEntfng
Spawner Not Active (enter settings) = Spawner nicht aktiv (Einstellungen eintragen)
Spawner Active (@1) = Spawner aktiv (@1)
Mob Spawner settings failed! = Mobspawnereinstellungen gescheitert!
> name min_light[0-14] max_light[0-14] max_mobs_in_area[0 to disable] distance[1-20] y_offset[-10 to 10] = Name min. Licht[0-14] max. Licht[0-14] max. Mobs in Gebiet[0 zum deaktivieren] Entfernung zum Spieler[1-20] Höhe[-10 bis 10]

36
locale/template.txt Normal file
View File

@ -0,0 +1,36 @@
# Template for translations of mobs_redo mod
# last update: 2016/June/10
#init.lua
[MOD] Mobs Redo loaded =
#api.lua
[MOBS] mod profiling enabled, damage not enabled =
lifetimer expired, removed @1 =
[Mobs Redo] @1 has spawning disabled =
[Mobs Redo] Chance setting for @1 is now @2 =
[mobs] @1 failed to spawn at @2 =
Not tamed! =
@1 is owner! =
Missed! =
@1 at full health (@2) =
@1 has been tamed! =
Enter name: =
Rename =
#crafts.lua
Nametag =
Leather =
Raw Meat =
Meat =
Magic Lasso (right-click animal to put in inventory) =
Net (right-click animal to put in inventory) =
Steel Shears (right-click to shear) =
#spawner.lua
Mob Spawner =
Mob MinLight MaxLight Amount PlayerDist =
Spawner Not Active (enter settings) =
Spawner Active (@1) =
Mob Spawner settings failed! =
> name min_light[0-14] max_light[0-14] max_mobs_in_area[0 to disable] distance[1-20] y_offset[-10 to 10] =

View File

@ -1,4 +1,6 @@
local S = mobs.intllib
-- mob spawner -- mob spawner
local spawner_default = "mobs_animal:pumba 10 15 0 0" local spawner_default = "mobs_animal:pumba 10 15 0 0"
@ -8,7 +10,7 @@ minetest.register_node("mobs:spawner", {
drawtype = "glasslike", drawtype = "glasslike",
paramtype = "light", paramtype = "light",
walkable = true, walkable = true,
description = "Mob Spawner", description = S("Mob Spawner"),
groups = {cracky = 1}, groups = {cracky = 1},
on_construct = function(pos) on_construct = function(pos)
@ -16,8 +18,9 @@ minetest.register_node("mobs:spawner", {
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
-- text entry formspec -- text entry formspec
meta:set_string("formspec", "field[text;Mob MinLight MaxLight Amount PlayerDist;${command}]") meta:set_string("formspec",
meta:set_string("infotext", "Spawner Not Active (enter settings)") "field[text;" .. S("Mob MinLight MaxLight Amount PlayerDist") .. ";${command}]")
meta:set_string("infotext", S("Spawner Not Active (enter settings)"))
meta:set_string("command", spawner_default) meta:set_string("command", spawner_default)
end, end,
@ -58,11 +61,12 @@ minetest.register_node("mobs:spawner", {
and yof and yof > -10 and yof < 10 then and yof and yof > -10 and yof < 10 then
meta:set_string("command", fields.text) meta:set_string("command", fields.text)
meta:set_string("infotext", "Spawner Active (" .. mob .. ")") meta:set_string("infotext", S("Spawner Active (@1)", mob))
else else
minetest.chat_send_player(name, "Mob Spawner settings failed!") minetest.chat_send_player(name, S("Mob Spawner settings failed!"))
minetest.chat_send_player(name, "> name min_light[0-14] max_light[0-14] max_mobs_in_area[0 to disable] distance[1-20] y_offset[-10 to 10]") minetest.chat_send_player(name,
S("> name min_light[0-14] max_light[0-14] max_mobs_in_area[0 to disable] distance[1-20] y_offset[-10 to 10]"))
end end
end, end,
}) })