From b1fbe88bc244d5ccbc05bfda216ccd6cc56b5eb9 Mon Sep 17 00:00:00 2001 From: Montandalar Date: Tue, 6 Feb 2024 01:30:57 +1100 Subject: [PATCH] Add translation support and German translation (#19) --- beacon.lua | 14 +++++++++---- extender.lua | 14 +++++++++++-- functions.lua | 22 +++++++++++---------- key.lua | 3 ++- locale/telemosaic.de.tr | 44 +++++++++++++++++++++++++++++++++++++++++ locale/template.txt | 44 +++++++++++++++++++++++++++++++++++++++++ 6 files changed, 124 insertions(+), 17 deletions(-) create mode 100644 locale/telemosaic.de.tr create mode 100644 locale/template.txt diff --git a/beacon.lua b/beacon.lua index 8eac266..09b3602 100644 --- a/beacon.lua +++ b/beacon.lua @@ -1,12 +1,15 @@ +local S = minetest.get_translator("telemosaic") for _,protected in pairs({true, false}) do local node_name_suffix = protected and "_protected" or "" local texture_overlay = protected and "^telemosaic_beacon_protected_overlay.png" or "" + local description = protected and "Protected Telemosaic Beacon" + or "Telemosaic Beacon" local description_prefix = protected and "Protected " or "" minetest.register_node("telemosaic:beacon_off"..node_name_suffix, { - description = description_prefix.."Telemosaic Beacon", + description = S(description), tiles = { "telemosaic_beacon_off.png"..texture_overlay, "telemosaic_beacon_side.png", @@ -18,7 +21,8 @@ for _,protected in pairs({true, false}) do }) minetest.register_node("telemosaic:beacon"..node_name_suffix, { - description = description_prefix.."Telemosaic Beacon Active (you hacker you!)", + description = S(description_prefix .. + "Telemosaic Beacon Active (you hacker you!)"), tiles = { "telemosaic_beacon_top.png"..texture_overlay, "telemosaic_beacon_side.png", @@ -31,7 +35,8 @@ for _,protected in pairs({true, false}) do }) minetest.register_node("telemosaic:beacon_err"..node_name_suffix, { - description = description_prefix.."Telemosaic Beacon Error (you hacker you!)", + description = S(description_prefix .. + "Telemosaic Beacon Error (you hacker you!)"), tiles = { "telemosaic_beacon_err.png"..texture_overlay, "telemosaic_beacon_side.png", @@ -44,7 +49,8 @@ for _,protected in pairs({true, false}) do }) minetest.register_node("telemosaic:beacon_disabled"..node_name_suffix, { - description = description_prefix.."Telemosaic Beacon Disabled (you hacker you!)", + description = S(description_prefix .. + "Telemosaic Beacon Disabled (you hacker you!)"), tiles = { "telemosaic_beacon_disabled.png"..texture_overlay, "telemosaic_beacon_side.png", diff --git a/extender.lua b/extender.lua index 73f4bb3..9b2586c 100644 --- a/extender.lua +++ b/extender.lua @@ -1,3 +1,4 @@ +local S = minetest.get_translator("telemosaic") local has_dye = minetest.get_modpath("dye") @@ -16,8 +17,17 @@ local tiers = {"one", "two", "three"} for i, range in pairs(telemosaic.extender_ranges) do local tier = tiers[i] + local common_desc, basic_desc + if has_dye then + common_desc = S("Telemosaic Extender, Tier @1 (@2)") + basic_desc = S(common_desc, i, S("Grey")) + else + common_desc = "Telemosaic Extender, Tier @1" + basic_desc = S(common_desc, i) + end + minetest.register_node("telemosaic:extender_"..tier, { - description = "Telemosaic Extender, Tier "..i..(has_dye and " (Grey)" or ""), + description = basic_desc, tiles = { "telemosaic_extender_"..tier..".png" }, @@ -36,7 +46,7 @@ for i, range in pairs(telemosaic.extender_ranges) do for name, color in pairs(telemosaic.extender_colors) do minetest.register_node("telemosaic:extender_"..tier.."_"..name, { - description = "Telemosaic Extender, Tier "..i.." ("..pretty_str(name)..")", + description = S(common_desc, i, S(pretty_str(name))), tiles = { "telemosaic_extender_"..tier..".png^[colorize:"..color }, diff --git a/functions.lua b/functions.lua index b6d12de..74f9e10 100644 --- a/functions.lua +++ b/functions.lua @@ -1,3 +1,4 @@ +local S = minetest.get_translator("telemosaic") -- Keeps a track of players to prevent teleport spamming local recent_teleports = {} @@ -146,7 +147,7 @@ function telemosaic.check_beacon(pos, player_name, all_checks) if player_name then local needed = math.ceil(dist - range) minetest.chat_send_player(player_name, - "You need to add extenders for "..needed.." nodes." + S("You need to add extenders for @1 node(s).", needed) ) end return false @@ -162,7 +163,7 @@ function telemosaic.check_beacon(pos, player_name, all_checks) if player_name then if telemosaic.is_protected_beacon(dest, player_name) then minetest.chat_send_player(player_name, - "Destination is protected." + S("Destination is protected.") ) return false end @@ -172,14 +173,14 @@ function telemosaic.check_beacon(pos, player_name, all_checks) if not valid then if player_name then minetest.chat_send_player(player_name, - "No telemosaic at destination." + S("No telemosaic at destination.") ) end return false elseif not open then if player_name then minetest.chat_send_player(player_name, - "Destination is blocked." + S("Destination is blocked.") ) end return false @@ -278,10 +279,11 @@ function telemosaic.rightclick(pos, node, player, itemstack, pointed_thing) -- Try to create a telemosaic key if itemstack:get_count() ~= 1 then minetest.chat_send_player(player_name, - "You can only use a singular mese crystal fragment to create a telemosaic key." + S("You can only use a singular mese crystal fragment to create a telemosaic key.") ) else - minetest.log("action", "[telemosaic] " .. player_name .. " created a key for the telemosaic at " + minetest.log("action", "[telemosaic] " .. player_name .. + " created a key for the telemosaic at " .. minetest.pos_to_string(pos)) return ItemStack({name = "telemosaic:key", metadata = hash_pos(pos)}) end @@ -295,12 +297,12 @@ function telemosaic.rightclick(pos, node, player, itemstack, pointed_thing) if not dest then -- This should never happen, but tell the player if it does minetest.chat_send_player(player_name, - "Telemosaic key is invalid." + S("Telemosaic key is invalid.") ) elseif not telemosaic.is_valid_destination(dest) then -- No point setting a destination that doesn't exist minetest.chat_send_player(player_name, - "No telemosaic at new destination." + S("No telemosaic at new destination.") ) else -- Everything is good, set the destination and update the telemosaic @@ -342,7 +344,7 @@ function telemosaic.rightclick(pos, node, player, itemstack, pointed_thing) telemosaic.teleport(player, pos, dest) else minetest.chat_send_player(player_name, - "Travel to destination is not allowed." + S("Travel to destination is not allowed.") ) end end @@ -350,7 +352,7 @@ function telemosaic.rightclick(pos, node, player, itemstack, pointed_thing) elseif state == "disabled" then -- Tell the player why they can't use this telemosaic minetest.chat_send_player(player_name, - "Telemosaic is disabled." + S("Telemosaic is disabled.") ) elseif state == "error" then diff --git a/key.lua b/key.lua index 80eddf2..268d8d6 100644 --- a/key.lua +++ b/key.lua @@ -1,6 +1,7 @@ +local S = minetest.get_translator("telemosaic") minetest.register_tool("telemosaic:key", { - description = "Telemosaic Key", + description = S("Telemosaic Key"), inventory_image = "telemosaic_key.png", stack_max = 1, groups = {not_in_creative_inventory = 1}, diff --git a/locale/telemosaic.de.tr b/locale/telemosaic.de.tr new file mode 100644 index 0000000..f5ae79b --- /dev/null +++ b/locale/telemosaic.de.tr @@ -0,0 +1,44 @@ +# textdomain: telemosaic +##[ beacon.lua ]## +Protected Telemosaic Beacon=Geschütztes Telemosaik-Leuchtfeuer +Telemosaic Beacon=Telemosaik-Leuchtfeuer +Telemosaic Beacon Active (you hacker you!)=Telemosaik-Leuchtfeuer aktiv (du Hacker du!) +Protected Telemosaic Beacon Active (you hacker you!)=Geschütztes Telemosaik-Leuchtfeuer aktiv (du Hacker du!) +Telemosaic Beacon Error (you hacker you!)=Telemosaik-Leuchtfeuer fehlerhaft (du Hacker du!) +Protected Telemosaic Beacon Error (you hacker you!)=Geschütztes Telemosaik-Leuchtfeuer fehlerhaft (du Hacker du!) +Telemosaic Beacon Disabled (you hacker you!)=Telemosaik-Leuchtfeuer deaktiviert (du Hacker du!) +Protected Telemosaic Beacon Disabled (you hacker you!)=Geschütztes Telemosaik-Leuchtfeuer deaktiviert (du Hacker du!) + +##[ extender.lua ]## +Telemosaic Extender, Tier @1 (@2)=Telemosaik-Verstärker Stufe @1 (@2) +Telemosaic Extender, Tier @1=Telemosaik-Verstärker Stufe @1 +# Aus MTG Wolle +Grey=Grau +White=Weiß +Dark Grey=Dunkelgrau +Black=Schwarz +Violet=Violett +Blue=Blau +Cyan=Türkis +Dark Green=Dunkelgrün +Green=Grün +Yellow=Gelb +Brown=Braun +Orange=Orange +Red=Rot +Magenta=Magenta +Pink=Rosa + +##[ functions.lua ]## +You need to add extenders for @1 node(s).=Sie müssen Verstärker für @1 Node(n) hinzufügen. +Destination is protected.=Zielort ist geschützt. +No telemosaic at destination.=Kein Telemosaik am Zielort. +Destination is blocked.=Zielort ist blockiert. +You can only use a singular mese crystal fragment to create a telemosaic key.=Sie können nur ein einzelnes Mesekristallfragment verwenden, um einen Telemosaik-Schlüssel zu erstellen. +Telemosaic key is invalid.=Telemosaik-Schlüssel ist ungültig. +No telemosaic at new destination.=Kein Telemosaik am neuen Zielort. +Travel to destination is not allowed.=Reisen zum Zielort ist nicht erlaubt. +Telemosaic is disabled.=Telemosaik ist deaktiviert. + +##[ key.lua ]## +Telemosaic Key=Telemosaik-Schlüssel diff --git a/locale/template.txt b/locale/template.txt new file mode 100644 index 0000000..aa65ed3 --- /dev/null +++ b/locale/template.txt @@ -0,0 +1,44 @@ +# textdomain: telemosaic +##[ beacon.lua ]## +Protected Telemosaic Beacon= +Telemosaic Beacon= +Telemosaic Beacon Active (you hacker you!)= +Protected Telemosaic Beacon Active (you hacker you!)= +Telemosaic Beacon Error (you hacker you!)= +Protected Telemosaic Beacon Error (you hacker you!)= +Telemosaic Beacon Disabled (you hacker you!)= +Protected Telemosaic Beacon Disabled (you hacker you!)= + +##[ extender.lua ]## +Telemosaic Extender, Tier @1 (@2)= +Telemosaic Extender, Tier @1= +Grey= +# from MTG wool +White= +Dark Grey= +Black= +Violet= +Blue= +Cyan= +Dark Green= +Green= +Yellow= +Brown= +Orange= +Red= +Magenta= +Pink= + +##[ functions.lua ]## +You need to add extenders for @1 node(s).= +Destination is protected.= +No telemosaic at destination.= +Destination is blocked.= +You can only use a singular mese crystal fragment to create a telemosaic key.= +Telemosaic key is invalid.= +No telemosaic at new destination.= +Travel to destination is not allowed.= +Telemosaic is disabled.= + +##[ key.lua ]## +Telemosaic Key=