From 803f5ee4b24a666e091c0fa0703c665fc1c77b6d Mon Sep 17 00:00:00 2001 From: TenPlus1 Date: Wed, 1 Feb 2017 20:35:04 +0000 Subject: [PATCH] Added intllib support (german translation by Xanthin) --- README.md | 5 +++-- depends.txt | 3 ++- init.lua | 51 ++++++++++++++++++++++++++------------------- locale/de.txt | 11 ++++++++++ locale/template.txt | 10 +++++++++ 5 files changed, 56 insertions(+), 24 deletions(-) create mode 100644 locale/de.txt create mode 100644 locale/template.txt diff --git a/README.md b/README.md index 32d2e0b..099ce04 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,8 @@ Change log: - 0.8 - Added Napiophelios' new textures and tweaked code - 0.9 - Added support for Wine mod's wine barrels - 1.0 - New furances do not work properly with hoppers so old reverted to abm furnaces -- 1.1 - Hoppers now work with new node timer Furnaces. Reduced Abm's and tidied code. -- 1.2 - Added simple API so that hoppers can work with other containers. +- 1.1 - Hoppers now work with new node timer Furnaces. Reduced Abm's and tidied code +- 1.2 - Added simple API so that hoppers can work with other containers +- 1.3 - Tweaked code to use a single abm and added intllib support Lucky Blocks: 2 diff --git a/depends.txt b/depends.txt index 8035459..53a9e75 100644 --- a/depends.txt +++ b/depends.txt @@ -1,2 +1,3 @@ default -lucky_block? \ No newline at end of file +intllib? +lucky_block? diff --git a/init.lua b/init.lua index b427503..23e8abd 100644 --- a/init.lua +++ b/init.lua @@ -3,6 +3,21 @@ hopper = {} +-- Intllib +local S + +if minetest.get_modpath("intllib") then + S = intllib.Getter() +else + S = function(s, a, ...) a = {a, ...} + return s:gsub("@(%d+)", function(n) + return a[tonumber(n)] + end) + end + +end + + -- default containers local containers = { @@ -79,7 +94,7 @@ end -- hopper minetest.register_node("hopper:hopper", { - description = "Hopper (Place onto side of container for side-hopper)", + description = S("Hopper (Place onto sides for side-hopper)"), groups = {cracky = 3}, drawtype = "nodebox", paramtype = "light", @@ -157,23 +172,20 @@ minetest.register_node("hopper:hopper", { on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) - minetest.log("action", player:get_player_name() - .." moves stuff in hopper at " - ..minetest.pos_to_string(pos)) + minetest.log("action", S("@1 moves stuff in hopper at @2", + player:get_player_name(), minetest.pos_to_string(pos))) end, on_metadata_inventory_put = function(pos, listname, index, stack, player) - minetest.log("action", player:get_player_name() - .." moves stuff to hopper at " - ..minetest.pos_to_string(pos)) + minetest.log("action", S("@1 moves stuff to hopper at @2", + player:get_player_name(), minetest.pos_to_string(pos))) end, on_metadata_inventory_take = function(pos, listname, index, stack, player) - minetest.log("action", player:get_player_name() - .." takes stuff from hopper at " - ..minetest.pos_to_string(pos)) + minetest.log("action", S("@1 moves stuff from hopper at @2", + player:get_player_name(), minetest.pos_to_string(pos))) end, on_rotate = screwdriver.disallow, @@ -182,7 +194,7 @@ minetest.register_node("hopper:hopper", { -- side hopper minetest.register_node("hopper:hopper_side", { - description = "Side Hopper (Place into crafting to return normal Hopper)", + description = S("Side Hopper (Place into crafting to return normal Hopper)"), groups = {cracky = 3, not_in_creative_inventory = 1}, drawtype = "nodebox", paramtype = "light", @@ -236,23 +248,20 @@ minetest.register_node("hopper:hopper_side", { on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) - minetest.log("action", player:get_player_name() - .." moves stuff in hopper at " - ..minetest.pos_to_string(pos)) + minetest.log("action", S("@1 moves stuff in hopper at @2", + player:get_player_name(), minetest.pos_to_string(pos))) end, on_metadata_inventory_put = function(pos, listname, index, stack, player) - minetest.log("action", player:get_player_name() - .." moves stuff to hopper at " - ..minetest.pos_to_string(pos)) + minetest.log("action", S("@1 moves stuff to hopper at @2", + player:get_player_name(), minetest.pos_to_string(pos))) end, on_metadata_inventory_take = function(pos, listname, index, stack, player) - minetest.log("action", player:get_player_name() - .." takes stuff from hopper at " - ..minetest.pos_to_string(pos)) + minetest.log("action", S("@1 moves stuff from hopper at @2", + player:get_player_name(), minetest.pos_to_string(pos))) end, on_rotate = screwdriver.rotate_simple, @@ -437,4 +446,4 @@ if minetest.get_modpath("lucky_block") then end -print ("[MOD] Hopper loaded") +print (S("[MOD] Hopper loaded")) diff --git a/locale/de.txt b/locale/de.txt new file mode 100644 index 0000000..e2249b6 --- /dev/null +++ b/locale/de.txt @@ -0,0 +1,11 @@ +# Template for translations of hopper mod +# German translation by Xanthin +# last update: 1st February 2017 + +#init.lua +[MOD] Hopper loaded = [MOD] Trichter geladen +Hopper (Place onto sides for side-hopper) = Trichter (für Seitentrichter an den Seiten platzieren) +Side Hopper (Place into crafting to return normal Hopper) = Seitentrichter (in Fertigungsraster legen, um normalen Trichter zu erhalten) +@1 moves stuff in hopper at @2 = @1 bewegt Dinge in einem Trichter bei @2 +@1 moves stuff to hopper at @2 = @1 verlagert Dinge in einen Trichter bei @2 +@1 moves stuff from hopper at @2 = @1 nimmt Dinge aus einem Trichter bei @2 diff --git a/locale/template.txt b/locale/template.txt new file mode 100644 index 0000000..0910e8d --- /dev/null +++ b/locale/template.txt @@ -0,0 +1,10 @@ +# Template for translations of hopper mod +# last update: 1st February 2017 + +#init.lua +[MOD] Hopper loaded = +Hopper (Place onto sides for side-hopper) = +Side Hopper (Place into crafting to return normal Hopper) = +@1 moves stuff in hopper at @2 +@1 moves stuff to hopper at @2 +@1 moves stuff from hopper at @2