Added intllib support (en/de)

This commit is contained in:
TenPlus1 2016-06-11 10:54:30 +01:00
parent 796589d1d6
commit 79ef481e86
6 changed files with 85 additions and 14 deletions

View File

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

View File

@ -1,8 +1,30 @@
local path = minetest.get_modpath("mobs_npc")
-- 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
-- NPC
dofile(path .. "/npc.lua") -- TenPlus1
dofile(path .. "/trader.lua")
print ("[MOD] Mobs Redo 'NPCs' loaded")
print (S("[MOD] Mobs Redo 'NPCs' loaded"))

23
locale/de.txt Normal file
View File

@ -0,0 +1,23 @@
# German Translation for mobs_npc mod
# Deutsche Übersetzung der mobs_npc Mod
# last update: 2016/June/10
# Author: Xanthin
#init.lua
[MOD] Mobs Redo 'NPCs' loaded = [MOD] Mobs Redo 'NPCs' geladen
#npc.lua
NPC dropped you an item for gold! = NSC ließ dir für Gold einen Gegenstand fallen!
NPC stands still. = NSC bleibt stehen.
NPC will follow you. = NSC wird dir folgen.
Npc = Nsc
#trader.lua
Trader @1 = Händler @1
[NPC] <Trader @1 > Hello, @2, have a look at my wares. = [NSC] <Händler @1 > Hallo, @2, wirf einen Blick auf meine Waren.
Trader @1's stock: = Händler @1s Warenlager
Selection = Auswahl
Price = Preis
Payment = Bezahlung
Bought items = Ware
Trader = Händler

21
locale/template.txt Normal file
View File

@ -0,0 +1,21 @@
# Template for translations of mobs_npc mod
# last update: 2016/June/10
#init.lua
[MOD] Mobs Redo 'NPCs' loaded =
#npc.lua
NPC dropped you an item for gold! =
NPC stands still. =
NPC will follow you. =
Npc =
#trader.lua
Trader @1 =
[NPC] <Trader @1 > Hello, @2, have a look at my wares. =
Trader @1's stock: =
Selection =
Price =
Payment =
Bought items =
Trader =

10
npc.lua
View File

@ -1,4 +1,6 @@
local S = mobs.intllib
-- Npc by TenPlus1
mobs.npc_drops = {
@ -83,7 +85,7 @@ mobs:register_mob("mobs_npc:npc", {
name = mobs.npc_drops[math.random(1, #mobs.npc_drops)]
})
minetest.chat_send_player(name, "NPC dropped you an item for gold!")
minetest.chat_send_player(name, S("NPC dropped you an item for gold!"))
return
end
@ -97,11 +99,11 @@ mobs:register_mob("mobs_npc:npc", {
if self.order == "follow" then
self.order = "stand"
minetest.chat_send_player(name, "NPC stands still.")
minetest.chat_send_player(name, S("NPC stands still."))
else
self.order = "follow"
minetest.chat_send_player(name, "NPC will follow you.")
minetest.chat_send_player(name, S("NPC will follow you."))
end
end
@ -111,7 +113,7 @@ mobs:register_mob("mobs_npc:npc", {
--mobs:register_spawn("mobs:npc", {"default:dirt_with_grass"}, 20, 0, 7000, 1, 31000)
--mobs:spawn_specific("mobs:npc", {"default:brick"}, {"air"}, 0, 15, 1, 1, 1, 0, 200, true)
mobs:register_egg("mobs_npc:npc", "Npc", "default_brick.png", 1)
mobs:register_egg("mobs_npc:npc", S("Npc"), "default_brick.png", 1)
-- compatibility
mobs:alias_mob("mobs:npc", "mobs_npc:npc")

View File

@ -1,4 +1,6 @@
local S = mobs.intllib
mobs.human = {
items = {
--{item for sale, price, chance of appearing in trader's inventory}
@ -247,7 +249,7 @@ function mobs_trader(self, clicker, entity, race)
if not self.game_name then
self.game_name = tostring(race.names[math.random(1, #race.names)])
self.nametag = "Trader " .. self.game_name
self.nametag = S("Trader @1", self.game_name)
self.object:set_properties({
nametag = self.nametag,
@ -327,27 +329,27 @@ function mobs_trader(self, clicker, entity, race)
mobs.add_goods(entity, race)
end
minetest.chat_send_player(player, "[NPC] <Trader " .. self.game_name
.. "> Hello, " .. player .. ", have a look at my wares.")
minetest.chat_send_player(player, S("[NPC] <Trader @1 > Hello, @2, have a look at my wares.",
self.game_name, player))
minetest.show_formspec(player, "trade", "size[8,10;]"
.. default.gui_bg_img
.. default.gui_slots
.. "label[0,0;Trader " .. self.game_name .. "'s stock:]"
.. "label[0,0;" .. S("Trader @1's stock:", self.game_name) .. "]"
.. "list[detached:" .. unique_entity_id .. ";goods;.5,.5;3,5;]"
.. "label[4.5,0.5;Selection]"
.. "label[4.5,0.5;" .. S("Selection") .. "]"
.. "list[detached:" .. unique_entity_id .. ";selection;4.5,1;5.5,2;]"
.. "label[6,0.5;Price]"
.. "label[6,0.5;" .. S("Price") .. "]"
.. "list[detached:" .. unique_entity_id .. ";price;6,1;7,2;]"
.. "label[4.5,3.5;Payment]"
.. "label[4.5,3.5;" .. S("Payment") .. "]"
.. "list[detached:" .. unique_entity_id .. ";payment;4.5,4;5.5,5;]"
.. "label[6,3.5;Bought items]"
.. "label[6,3.5;" .. S("Bought items") .. "]"
.. "list[detached:" .. unique_entity_id .. ";takeaway;6,4;7.5,5.5;]"
.. "list[current_player;main;0,6;8,4;]"
)
end
mobs:register_egg("mobs_npc:trader", "Trader", "default_sandstone.png", 1)
mobs:register_egg("mobs_npc:trader", S("Trader"), "default_sandstone.png", 1)
-- compatibility
mobs:alias_mob("mobs:trader", "mobs_npc:trader")