From f9e839435cc861dba3edb003be856aef7e47908c Mon Sep 17 00:00:00 2001 From: Jaidyn Ann Date: Wed, 3 Jan 2024 15:13:14 -0600 Subject: [PATCH] Add translation support --- locale/template.txt | 9 +++++++++ tools.lua | 26 ++++++++++++++------------ 2 files changed, 23 insertions(+), 12 deletions(-) create mode 100644 locale/template.txt diff --git a/locale/template.txt b/locale/template.txt new file mode 100644 index 0000000..d11246b --- /dev/null +++ b/locale/template.txt @@ -0,0 +1,9 @@ +# textdomain: spears +Stone Spear= +Iron Spear= +Steel Spear= +Copper Spear= +Bronze Spear= +Obsidian Spear= +Diamond Spear= +Golden Spear= diff --git a/tools.lua b/tools.lua index 2793408..68720e5 100644 --- a/tools.lua +++ b/tools.lua @@ -1,7 +1,9 @@ +local S = minetest.get_translator("spears") + function spears_register_spear(spear_type, desc, base_damage, toughness, material) minetest.register_tool("spears:spear_" .. spear_type, { - description = desc .. " spear", + description = desc, wield_image = "spears_spear_" .. spear_type .. ".png^[transform4", inventory_image = "spears_spear_" .. spear_type .. ".png", wield_scale= {x = 1.5, y = 1.5, z = 1.5}, @@ -55,43 +57,43 @@ function spears_register_spear(spear_type, desc, base_damage, toughness, materia end if not DISABLE_STONE_SPEAR then - spears_register_spear('stone', 'Stone', 4, 20, 'group:stone') + spears_register_spear('stone', S('Stone Spear'), 4, 20, 'group:stone') end if minetest.get_modpath("pigiron") then if not DISABLE_IRON_SPEAR then - spears_register_spear('iron', 'Iron', 5.5, 30, 'pigiron:iron_ingot') + spears_register_spear('iron', S('Iron Spear'), 5.5, 30, 'pigiron:iron_ingot') end if not DISABLE_STEEL_SPEAR then - spears_register_spear('steel', 'Steel', 6, 35, 'default:steel_ingot') + spears_register_spear('steel', S('Steel Spear'), 6, 35, 'default:steel_ingot') end if not DISABLE_COPPER_SPEAR then - spears_register_spear('copper', 'Copper', 4.8, 30, 'default:copper_ingot') + spears_register_spear('copper', S('Copper Spear'), 4.8, 30, 'default:copper_ingot') end if not DISABLE_BRONZE_SPEAR then - spears_register_spear('bronze', 'Bronze', 5.5, 35, 'default:bronze_ingot') + spears_register_spear('bronze', S('Bronze Spear'), 5.5, 35, 'default:bronze_ingot') end else if not DISABLE_STEEL_SPEAR then - spears_register_spear('steel', 'Steel', 6, 30, 'default:steel_ingot') + spears_register_spear('steel', S('Steel Spear'), 6, 30, 'default:steel_ingot') end if not DISABLE_COPPER_SPEAR then - spears_register_spear('copper', 'Copper', 5, 30, 'default:copper_ingot') + spears_register_spear('copper', S('Copper Spear'), 5, 30, 'default:copper_ingot') end if not DISABLE_BRONZE_SPEAR then - spears_register_spear('bronze', 'Bronze', 6, 35, 'default:bronze_ingot') + spears_register_spear('bronze', S('Bronze Spear'), 6, 35, 'default:bronze_ingot') end end if not DISABLE_OBSIDIAN_SPEAR then - spears_register_spear('obsidian', 'Obsidian', 8, 30, 'default:obsidian') + spears_register_spear('obsidian', S('Obsidian Spear'), 8, 30, 'default:obsidian') end if not DISABLE_DIAMOND_SPEAR then - spears_register_spear('diamond', 'Diamond', 8, 40, 'default:diamond') + spears_register_spear('diamond', S('Diamond Spear'), 8, 40, 'default:diamond') end if not DISABLE_GOLD_SPEAR then - spears_register_spear('gold', 'Golden', 5, 40, 'default:gold_ingot') + spears_register_spear('gold', S('Golden Spear'), 5, 40, 'default:gold_ingot') end