From 5a7fc3774f5991ffffe8d66f6681f05fcbe6febd Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Mon, 14 Dec 2020 14:08:55 +0100 Subject: [PATCH] Make mcl_enchantments translatable --- mods/CORE/mcl_enchanting/enchantments.lua | 154 +++++++++++----------- mods/CORE/mcl_enchanting/engine.lua | 9 +- mods/CORE/mcl_enchanting/init.lua | 49 +++---- 3 files changed, 109 insertions(+), 103 deletions(-) diff --git a/mods/CORE/mcl_enchanting/enchantments.lua b/mods/CORE/mcl_enchanting/enchantments.lua index 4ed94a0b37..c3bfa05df1 100644 --- a/mods/CORE/mcl_enchanting/enchantments.lua +++ b/mods/CORE/mcl_enchanting/enchantments.lua @@ -1,3 +1,5 @@ +local S = minetest.get_translator("mcl_enchanting") + -- Taken from https://minecraft.gamepedia.com/Enchanting local function increase_damage(damage_group, factor) @@ -10,14 +12,14 @@ end -- requires engine change --[[mcl_enchanting.enchantments.aqua_affinity = { - name = "Aqua Affinity", + name = S("Aqua Affinity"), max_level = 1, primary = {armor_head = true}, secondary = {}, disallow = {non_combat_armor = true}, incompatible = {}, weight = 2, - description = "Increases underwater mining speed.", + description = S("Increases underwater mining speed."), curse = false, on_enchant = function() end, requires_tool = false, @@ -27,14 +29,14 @@ end -- implemented via on_enchant and additions in mobs_mc; Slowness IV part unimplemented mcl_enchanting.enchantments.bane_of_arthropods = { - name = "Bane of Arthropods", + name = S("Bane of Arthropods"), max_level = 5, primary = {sword = true}, secondary = {axe = true}, disallow = {}, incompatible = {smite = true, shaprness = true}, weight = 5, - description = "Increases damage and applies Slowness IV to arthropod mobs (spiders, cave spiders, silverfish and endermites).", + description = S("Increases damage and applies Slowness IV to arthropod mobs (spiders, cave spiders, silverfish and endermites)."), curse = false, on_enchant = increase_damage("anthropod", 2.5), requires_tool = false, @@ -44,14 +46,14 @@ mcl_enchanting.enchantments.bane_of_arthropods = { -- implemented in mcl_armor mcl_enchanting.enchantments.blast_protection = { - name = "Blast Protection", + name = S("Blast Protection"), max_level = 4, primary = {armor_head = true, armor_torso = true, armor_legs = true, armor_feet = true}, secondary = {}, disallow = {non_combat_armor = true}, incompatible = {fire_protection = true, protection = true, projectile_protection = true}, weight = 2, - description = "Reduces explosion damage and knockback.", + description = S("Reduces explosion damage and knockback."), curse = false, on_enchant = function() end, requires_tool = false, @@ -61,14 +63,14 @@ mcl_enchanting.enchantments.blast_protection = { -- requires missing MineClone2 feature --[[mcl_enchanting.enchantments.channeling = { - name = "Channeling", + name = S("Channeling"), max_level = 1, primary = {trident = true}, secondary = {}, disallow = {}, incompatible = {riptide = true}, weight = 1, - description = "Trident \"channels\" a bolt of lightning toward a hit entity. Functions only during thunderstorms and if target is unobstructed with opaque blocks.", + description = S("Channels a bolt of lightning toward a target. Works only during thunderstorms and if target is unobstructed with opaque blocks."), curse = false, on_enchant = function() end, requires_tool = false, @@ -78,14 +80,14 @@ mcl_enchanting.enchantments.blast_protection = { -- implemented in mcl_armor mcl_enchanting.enchantments.curse_of_binding = { - name = "Curse of Binding", + name = S("Curse of Binding"), max_level = 1, primary = {}, secondary = {armor_head = true, armor_torso = true, armor_legs = true, armor_feet = true}, disallow = {}, incompatible = {}, weight = 1, - description = "Except when in creative mode, items cannot be removed from armor slots except due to death or breaking.", + description = S("Item cannot be removed from armor slots except due to death, breaking or in Creative Mode."), curse = true, on_enchant = function() end, requires_tool = false, @@ -95,14 +97,14 @@ mcl_enchanting.enchantments.curse_of_binding = { -- implemented in mcl_death_drop mcl_enchanting.enchantments.curse_of_vanishing = { - name = "Curse of Vanishing", + name = S("Curse of Vanishing"), max_level = 1, primary = {}, secondary = {armor_head = true, armor_torso = true, armor_legs = true, armor_feet = true, tool = true, weapon = true}, disallow = {}, incompatible = {}, weight = 1, - description = "Item destroyed on death.", + description = S("Item destroyed on death."), curse = true, on_enchant = function() end, requires_tool = false, @@ -112,14 +114,14 @@ mcl_enchanting.enchantments.curse_of_vanishing = { -- unimplemented --[[mcl_enchanting.enchantments.depth_strider = { - name = "Depth Strider", + name = S("Depth Strider"), max_level = 3, primary = {}, secondary = {armor_feet = true}, disallow = {non_combat_armor = true}, incompatible = {frost_walker = true}, weight = 2, - description = "Increases underwater movement speed.", + description = S("Increases underwater movement speed."), curse = false, on_enchant = function() end, requires_tool = false, @@ -129,14 +131,14 @@ mcl_enchanting.enchantments.curse_of_vanishing = { -- implemented via on_enchant mcl_enchanting.enchantments.efficiency = { - name = "Efficiency", + name = S("Efficiency"), max_level = 5, primary = {pickaxe = true, shovel = true, axe = true, hoe = true}, secondary = {shears = true}, disallow = {}, incompatible = {}, weight = 10, - description = "Increases mining speed.", + description = S("Increases mining speed."), curse = false, on_enchant = function(itemstack, level) local tool_capabilities = itemstack:get_tool_capabilities() @@ -156,14 +158,14 @@ mcl_enchanting.enchantments.efficiency = { -- implemented in mcl_armor mcl_enchanting.enchantments.feather_falling = { - name = "Feather Falling", + name = S("Feather Falling"), max_level = 4, primary = {armor_feet = true}, secondary = {}, disallow = {non_combat_armor = true}, incompatible = {}, weight = 5, - description = "Reduces fall damage.",curse = false, + description = S("Reduces fall damage."),curse = false, on_enchant = function() end, requires_tool = false, treasure = false, @@ -172,14 +174,14 @@ mcl_enchanting.enchantments.feather_falling = { -- requires missing MineClone2 feature --[[mcl_enchanting.enchantments.fire_aspect = { - name = "Fire Aspect", + name = S("Fire Aspect"), max_level = 2, primary = {sword = true}, secondary = {}, disallow = {}, incompatible = {}, weight = 2, - description = "Sets target on fire.", + description = S("Sets target on fire."), curse = false, on_enchant = function() end, requires_tool = false, @@ -189,14 +191,14 @@ mcl_enchanting.enchantments.feather_falling = { -- implemented in mcl_armor mcl_enchanting.enchantments.fire_protection = { - name = "Fire Protection", + name = S("Fire Protection"), max_level = 4, primary = {armor_head = true, armor_torso = true, armor_legs = true, armor_feet = true}, secondary = {}, disallow = {non_combat_armor = true}, incompatible = {blast_protection = true, protection = true, projectile_protection = true}, weight = 5, - description = "Reduces fire damage.", + description = S("Reduces fire damage."), curse = false, on_enchant = function() end, requires_tool = false, @@ -206,14 +208,14 @@ mcl_enchanting.enchantments.fire_protection = { -- requires missing MineClone2 feature --[[mcl_enchanting.enchantments.flame = { - name = "Flame", + name = S("Flame"), max_level = 1, primary = {bow = true}, secondary = {}, disallow = {}, incompatible = {}, weight = 2, - description = "Arrows set target on fire.", + description = S("Arrows set target on fire."), curse = false, on_enchant = function() end, requires_tool = false, @@ -223,14 +225,14 @@ mcl_enchanting.enchantments.fire_protection = { -- implemented in mcl_item_entity mcl_enchanting.enchantments.fortune = { - name = "Fortune", + name = S("Fortune"), max_level = 3, primary = {pickaxe = true, shovel = true, axe = true, hoe = true}, secondary = {}, disallow = {}, incompatible = {silk_touch = true}, weight = 2, - description = "Increases certain block drops.", + description = S("Increases certain block drops."), curse = false, on_enchant = function() end, requires_tool = false, @@ -240,14 +242,14 @@ mcl_enchanting.enchantments.fortune = { -- implemented via walkover.register_global mcl_enchanting.enchantments.frost_walker = { - name = "Frost Walker", + name = S("Frost Walker"), max_level = 2, primary = {}, secondary = {armor_feet = true}, disallow = {non_combat_armor = true}, incompatible = {depth_strider = true}, weight = 2, - description = "Turns water beneath the player into frosted ice and prevents the damage the player would take from standing on magma blocks.", + description = S("Turns water beneath the player into frosted ice and prevents the damage from magma blocks."), curse = false, on_enchant = function() end, requires_tool = false, @@ -274,14 +276,14 @@ end) -- requires missing MineClone2 feature --[[mcl_enchanting.enchantments.impaling = { - name = "Impaling", + name = S("Impaling"), max_level = 5, primary = {trident = true}, secondary = {}, disallow = {}, incompatible = {}, weight = 2, - description = "Trident deals additional damage to mobs that spawn naturally in the ocean.", + description = S("Trident deals additional damage to ocean mobs."), curse = false, on_enchant = function() end, requires_tool = false, @@ -291,14 +293,14 @@ end) -- implemented in mcl_bows mcl_enchanting.enchantments.infinity = { - name = "Infinity", + name = S("Infinity"), max_level = 1, primary = {bow = true}, secondary = {}, disallow = {}, incompatible = {mending = true}, weight = 1, - description = "Shooting consumes no regular arrows.", + description = S("Shooting consumes no regular arrows."), curse = false, on_enchant = function() end, requires_tool = false, @@ -308,14 +310,14 @@ mcl_enchanting.enchantments.infinity = { -- implemented via minetest.calculate_knockback mcl_enchanting.enchantments.knockback = { - name = "Knockback", + name = S("Knockback"), max_level = 2, primary = {sword = true}, secondary = {}, disallow = {}, incompatible = {}, weight = 5, - description = "Increases knockback.", + description = S("Increases knockback."), curse = false, on_enchant = function() end, requires_tool = false, @@ -341,14 +343,14 @@ end -- unimplemented --[[mcl_enchanting.enchantments.looting = { - name = "Looting", + name = S("Looting"), max_level = 3, primary = {sword = true}, secondary = {}, disallow = {}, incompatible = {}, weight = 2, - description = "Increases mob loot.", + description = S("Increases mob loot."), curse = false, on_enchant = function() end, requires_tool = false, @@ -358,14 +360,14 @@ end -- requires missing MineClone2 feature --[[mcl_enchanting.enchantments.loyalty = { - name = "Loyalty", + name = S("Loyalty"), max_level = 3, primary = {trident = true}, secondary = {}, disallow = {}, incompatible = {riptide = true}, weight = 5, - description = "Trident returns after being thrown. Higher levels reduce return time.", + description = S("Trident returns after being thrown. Higher levels reduce return time."), curse = false, on_enchant = function() end, requires_tool = false, @@ -375,14 +377,14 @@ end -- unimplemented --[[mcl_enchanting.enchantments.luck_of_the_sea = { - name = "Luck of the Sea", + name = S("Luck of the Sea"), max_level = 3, primary = {fishing_rod = true}, secondary = {}, disallow = {}, incompatible = {}, weight = 2, - description = "Increases rate of good loot (enchanting books, etc.)", + description = S("Increases rate of good loot (enchanting books, etc.)"), curse = false, on_enchant = function() end, requires_tool = false, @@ -392,14 +394,14 @@ end -- implemented in mcl_fishing mcl_enchanting.enchantments.lure = { - name = "Lure", + name = S("Lure"), max_level = 3, primary = {fishing_rod = true}, secondary = {}, disallow = {}, incompatible = {}, weight = 2, - description = "Decreases wait time until fish/junk/loot \"bites\".", + description = S("Decreases time until rod catches something."), curse = false, on_enchant = function() end, requires_tool = false, @@ -409,14 +411,14 @@ mcl_enchanting.enchantments.lure = { -- unimplemented --[[mcl_enchanting.enchantments.mending = { - name = "Mending", + name = S("Mending"), max_level = 1, primary = {}, secondary = {armor_head = true, armor_torso = true, armor_legs = true, armor_feet = true, tool = true, weapon = true}, disallow = {}, incompatible = {infinity = true}, weight = 2, - description = "Repair the item while gaining XP orbs.", + description = S("Repair the item while gaining XP orbs."), curse = false, on_enchant = function() end, requires_tool = true, @@ -426,14 +428,14 @@ mcl_enchanting.enchantments.lure = { -- requires missing MineClone2 feature --[[mcl_enchanting.enchantments.multishot = { - name = "Multishot", + name = S("Multishot"), max_level = 1, primary = {crossbow = true}, secondary = {}, disallow = {}, incompatible = {piercing = true}, weight = 2, - description = "Shoot 3 arrows at the cost of one.", + description = S("Shoot 3 arrows at the cost of one."), curse = false, on_enchant = function() end, requires_tool = false, @@ -443,14 +445,14 @@ mcl_enchanting.enchantments.lure = { -- requires missing MineClone2 feature --[[mcl_enchanting.enchantments.piercing = { - name = "Piercing", + name = S("Piercing"), max_level = 4, primary = {crossbow = true}, secondary = {}, disallow = {}, incompatible = {multishot = true}, weight = 10, - description = "Arrows pass through multiple entities.", + description = S("Arrows passes through multiple objects."), curse = false, on_enchant = function() end, requires_tool = false, @@ -460,14 +462,14 @@ mcl_enchanting.enchantments.lure = { -- implemented in mcl_bows mcl_enchanting.enchantments.power = { - name = "Power", + name = S("Power"), max_level = 5, primary = {bow = true}, secondary = {}, disallow = {}, incompatible = {}, weight = 10, - description = "Increases arrow damage.", + description = S("Increases arrow damage."), curse = false, on_enchant = function() end, requires_tool = false, @@ -477,14 +479,14 @@ mcl_enchanting.enchantments.power = { -- implemented in mcl_armor mcl_enchanting.enchantments.projectile_protection = { - name = "Projectile Protection", + name = S("Projectile Protection"), max_level = 4, primary = {armor_head = true, armor_torso = true, armor_legs = true, armor_feet = true}, secondary = {}, disallow = {non_combat_armor = true}, incompatible = {blast_protection = true, fire_protection = true, protection = true}, weight = 5, - description = "Reduces projectile damage.", + description = S("Reduces projectile damage."), curse = false, on_enchant = function() end, requires_tool = false, @@ -494,14 +496,14 @@ mcl_enchanting.enchantments.projectile_protection = { -- implemented in mcl_armor mcl_enchanting.enchantments.protection = { - name = "Protection", + name = S("Protection"), max_level = 4, primary = {armor_head = true, armor_torso = true, armor_legs = true, armor_feet = true}, secondary = {}, disallow = {non_combat_armor = true}, incompatible = {blast_protection = true, fire_protection = true, projectile_protection = true}, weight = 10, - description = "Reduces most types of damage by 4% for each level.", + description = S("Reduces most types of damage by 4% for each level."), curse = false, on_enchant = function() end, requires_tool = false, @@ -511,14 +513,14 @@ mcl_enchanting.enchantments.protection = { -- implemented via minetest.calculate_knockback (together with the Knockback enchantment) and mcl_bows mcl_enchanting.enchantments.punch = { - name = "Punch", + name = S("Punch"), max_level = 2, primary = {}, secondary = {bow = true}, disallow = {}, incompatible = {}, weight = 2, - description = "Increases arrow knockback.", + description = S("Increases arrow knockback."), curse = false, on_enchant = function() end, requires_tool = false, @@ -528,14 +530,14 @@ mcl_enchanting.enchantments.punch = { -- requires missing MineClone2 feature --[[mcl_enchanting.enchantments.quick_charge = { - name = "Quick Charge", + name = S("Quick Charge"), max_level = 3, primary = {crossbow = true}, secondary = {}, disallow = {}, incompatible = {}, weight = 5, - description = "Decreases crossbow charging time.", + description = S("Decreases crossbow charging time."), curse = false, on_enchant = function() end, requires_tool = false, @@ -545,14 +547,14 @@ mcl_enchanting.enchantments.punch = { -- unimplemented --[[mcl_enchanting.enchantments.respiration = { - name = "Respiration", + name = S("Respiration"), max_level = 3, primary = {armor_head = true}, secondary = {}, disallow = {non_combat_armor = true}, incompatible = {}, weight = 2, - description = "Extends underwater breathing time.", + description = S("Extends underwater breathing time."), curse = false, on_enchant = function() end, requires_tool = false, @@ -562,14 +564,14 @@ mcl_enchanting.enchantments.punch = { -- requires missing MineClone2 feature --[[mcl_enchanting.enchantments.riptide = { - name = "Riptide", + name = S("Riptide"), max_level = 3, primary = {trident = true}, secondary = {}, disallow = {}, incompatible = {channeling = true, loyalty = true}, weight = 2, - description = "Trident launches player with itself when thrown. Functions only in water or rain.", + description = S("Trident launches player with itself when thrown. Works only in water or rain."), curse = false, on_enchant = function() end, requires_tool = false, @@ -579,14 +581,14 @@ mcl_enchanting.enchantments.punch = { -- implemented via on_enchant mcl_enchanting.enchantments.sharpness = { - name = "Sharpness", + name = S("Sharpness"), max_level = 5, primary = {sword = true}, secondary = {axe = true}, disallow = {}, incompatible = {bane_of_arthropods = true, smite = true}, weight = 5, - description = "Increases damage.", + description = S("Increases damage."), curse = false, on_enchant = increase_damage("fleshy", 0.5), requires_tool = false, @@ -596,14 +598,14 @@ mcl_enchanting.enchantments.sharpness = { -- implemented in mcl_item_entity mcl_enchanting.enchantments.silk_touch = { - name = "Silk Touch", + name = S("Silk Touch"), max_level = 1, primary = {pickaxe = true, shovel = true, axe = true, hoe = true}, secondary = {shears = true}, disallow = {}, incompatible = {fortune = true}, weight = 1, - description = "Mined blocks drop themselves.", + description = S("Mined blocks drop themselves."), curse = false, on_enchant = function() end, requires_tool = false, @@ -613,14 +615,14 @@ mcl_enchanting.enchantments.silk_touch = { -- implemented via on_enchant and additions in mobs_mc mcl_enchanting.enchantments.smite = { - name = "Smite", + name = S("Smite"), max_level = 5, primary = {sword = true}, secondary = {axe = true}, disallow = {}, incompatible = {bane_of_arthropods = true, sharpness = true}, weight = 5, - description = "Increases damage to undead mobs.", + description = S("Increases damage to undead mobs."), curse = false, on_enchant = increase_damage("undead", 2.5), requires_tool = false, @@ -630,14 +632,14 @@ mcl_enchanting.enchantments.smite = { -- implemented in mcl_playerplus mcl_enchanting.enchantments.soul_speed = { - name = "Soul Speed", + name = S("Soul Speed"), max_level = 3, primary = {}, secondary = {armor_feet = true}, disallow = {non_combat_armor = true}, incompatible = {frost_walker = true}, weight = 2, - description = "Increases walking speed on soul sand.", + description = S("Increases walking speed on soul sand."), curse = false, on_enchant = function() end, requires_tool = false, @@ -647,14 +649,14 @@ mcl_enchanting.enchantments.soul_speed = { -- requires missing MineClone2 feature --[[mcl_enchanting.enchantments.sweeping_edge = { - name = "Sweeping Edge", + name = S("Sweeping Edge"), max_level = 3, primary = {sword = true}, secondary = {}, disallow = {}, incompatible = {}, weight = 2, - description = "Increases sweeping attack damage.", + description = S("Increases sweeping attack damage."), curse = false, on_enchant = function() end, requires_tool = false, @@ -664,14 +666,14 @@ mcl_enchanting.enchantments.soul_speed = { -- implemented in mcl_armor mcl_enchanting.enchantments.thorns = { - name = "Thorns", + name = S("Thorns"), max_level = 3, primary = {armor_head = true}, secondary = {armor_torso = true, armor_legs = true, armor_feet = true}, disallow = {non_combat_armor = true}, incompatible = {blast_protection = true, fire_protection = true, projectile_protection = true}, weight = 1, - description = "Reflects some of the damage taken when hit, at the cost of reducing durability with each proc.", + description = S("Reflects some of the damage taken when hit, at the cost of reducing durability with each proc."), curse = false, on_enchant = function() end, requires_tool = false, @@ -681,14 +683,14 @@ mcl_enchanting.enchantments.thorns = { -- for tools & weapons implemented via on_enchant; for bows implemented in mcl_bows; for armor implemented in mcl_armor and mcl_tt; for fishing rods implemented in mcl_fishing mcl_enchanting.enchantments.unbreaking = { - name = "Unbreaking", + name = S("Unbreaking"), max_level = 3, primary = {armor_head = true, armor_torso = true, armor_legs = true, armor_feet = true, pickaxe = true, shovel = true, axe = true, hoe = true, sword = true, fishing_rod = true, bow = true}, secondary = {tool = true}, disallow = {non_combat_armor = true}, incompatible = {}, weight = 5, - description = "Increases item durability.", + description = S("Increases item durability."), curse = false, on_enchant = function(itemstack, level) local tool_capabilities = itemstack:get_tool_capabilities() diff --git a/mods/CORE/mcl_enchanting/engine.lua b/mods/CORE/mcl_enchanting/engine.lua index 1202ec70df..ecf0c21523 100644 --- a/mods/CORE/mcl_enchanting/engine.lua +++ b/mods/CORE/mcl_enchanting/engine.lua @@ -1,3 +1,6 @@ +local S = minetest.get_translator("mcl_enchanting") +local F = minetest.formspec_escape + function mcl_enchanting.is_book(itemname) return itemname == "mcl_books:book" or itemname == "mcl_enchanting:book_enchanted" end @@ -388,13 +391,13 @@ function mcl_enchanting.show_enchanting_formspec(player) local formspec = "" .. "size[9.07,8.6;]" .. "formspec_version[3]" - .. "label[0,0;" .. C("#313131") .. table_name .. "]" + .. "label[0,0;" .. C("#313131") .. F(table_name) .. "]" .. mcl_formspec.get_itemslot_bg(0.2, 2.4, 1, 1) .. "list[detached:" .. name .. "_enchanting;enchanting;0.2,2.4;1,1;1]" .. mcl_formspec.get_itemslot_bg(1.1, 2.4, 1, 1) .. "image[1.1,2.4;1,1;mcl_enchanting_lapis_background.png]" .. "list[detached:" .. name .. "_enchanting;enchanting;1.1,2.4;1,1;2]" - .. "label[0,4;" .. C("#313131") .. "Inventory]" + .. "label[0,4;" .. C("#313131") .. F(S("Inventory")).."]" .. mcl_formspec.get_itemslot_bg(0, 4.5, 9, 3) .. mcl_formspec.get_itemslot_bg(0, 7.74, 9, 1) .. "list[current_player;main;0,4.5;9,3;9]" @@ -417,7 +420,7 @@ function mcl_enchanting.show_enchanting_formspec(player) local hover_ending = (can_enchant and "_hovered" or "_off") formspec = formspec .. "container[3.2," .. y .. "]" - .. (slot and "tooltip[button_" .. i .. ";" .. C("#818181") .. slot.description .. " " .. C("#FFFFFF") .. " . . . ?\n\n" .. (enough_levels and C(enough_lapis and "#818181" or "#FC5454") .. i .. " Lapis Lazuli\n" .. C("#818181") .. i .. " Enchantment Levels" or C("#FC5454") .. "Level Requirement: " .. slot.level_requirement) .. "]" or "") + .. (slot and "tooltip[button_" .. i .. ";" .. C("#818181") .. F(slot.description) .. " " .. C("#FFFFFF") .. " . . . ?\n\n" .. (enough_levels and C(enough_lapis and "#818181" or "#FC5454") .. F(S("@1 × Lapis Lazuli", i)) .. "\n" .. C("#818181") .. F(S("Enchantment levels: @1", i)) or C("#FC5454") .. F(S("Level requirement: @1", slot.level_requirement))) .. "]" or "") .. "style[button_" .. i .. ";bgimg=mcl_enchanting_button" .. ending .. ".png;bgimg_hovered=mcl_enchanting_button" .. hover_ending .. ".png;bgimg_pressed=mcl_enchanting_button" .. hover_ending .. ".png]" .. "button[0,0;7.5,1.3;button_" .. i .. ";]" .. (slot and "image[0,0;1.3,1.3;mcl_enchanting_number_" .. i .. ending .. ".png]" or "") diff --git a/mods/CORE/mcl_enchanting/init.lua b/mods/CORE/mcl_enchanting/init.lua index d1f351b629..fbfc806193 100644 --- a/mods/CORE/mcl_enchanting/init.lua +++ b/mods/CORE/mcl_enchanting/init.lua @@ -1,4 +1,5 @@ local modpath = minetest.get_modpath("mcl_enchanting") +local S = minetest.get_translator("mcl_enchanting") mcl_enchanting = { book_offset = vector.new(0, 0.75, 0), @@ -58,8 +59,8 @@ dofile(modpath .. "/engine.lua") dofile(modpath .. "/enchantments.lua") minetest.register_chatcommand("enchant", { - description = "Enchant an item.", - params = " []", + description = S("Enchant an item"), + params = S(" []"), privs = {give = true}, func = function(_, param) local sparam = param:split(" ") @@ -68,40 +69,40 @@ minetest.register_chatcommand("enchant", { local level_str = sparam[3] local level = tonumber(level_str or "1") if not target_name or not enchantment then - return false, "Usage: /enchant []" + return false, S("Usage: /enchant []") end local target = minetest.get_player_by_name(target_name) if not target then - return false, "Player '" .. target_name .. "' cannot be found" + return false, S("Player '@1' cannot be found.", target_name) end local itemstack = target:get_wielded_item() local can_enchant, errorstring, extra_info = mcl_enchanting.can_enchant(itemstack, enchantment, level) if not can_enchant then if errorstring == "enchantment invalid" then - return false, "There is no such enchantment '" .. enchantment .. "'" + return false, S("There is no such enchantment '@1'.", enchantment) elseif errorstring == "item missing" then - return false, "The target doesn't hold an item" + return false, S("The target doesn't hold an item.") elseif errorstring == "item not supported" then - return false, "The selected enchantment can't be added to the target item" + return false, S("The selected enchantment can't be added to the target item.") elseif errorstring == "level invalid" then - return false, "'" .. level_str .. "' is not a valid number" + return false, S("'@1' is not a valid number", level_str) elseif errorstring == "level too high" then - return false, "The number you have entered (" .. level_str .. ") is too big, it must be at most " .. extra_info + return false, S("The number you have entered (@1) is too big, it must be at most @2.", level_str, extra_info) elseif errorstring == "level too small" then - return false, "The number you have entered (" .. level_str .. ") is too small, it must be at least " .. extra_info + return false, S("The number you have entered (@1) is too small, it must be at least @2.", level_str, extra_info) elseif errorstring == "incompatible" then - return false, mcl_enchanting.get_enchantment_description(enchantment, level) .. " can't be combined with " .. extra_info + return false, S("@1 can't be combined with @2.", mcl_enchanting.get_enchantment_description(enchantment, level), extra_info) end else target:set_wielded_item(mcl_enchanting.enchant(itemstack, enchantment, level)) - return true, "Enchanting succeded" + return true, S("Enchanting succeded.") end end }) minetest.register_chatcommand("forceenchant", { - description = "Forcefully enchant an item.", - params = " []", + description = S("Forcefully enchant an item"), + params = S(" []"), func = function(_, param) local sparam = param:split(" ") local target_name = sparam[1] @@ -109,31 +110,31 @@ minetest.register_chatcommand("forceenchant", { local level_str = sparam[3] local level = tonumber(level_str or "1") if not target_name or not enchantment then - return false, "Usage: /forceenchant []" + return false, S("Usage: /forceenchant []") end local target = minetest.get_player_by_name(target_name) if not target then - return false, "Player '" .. target_name .. "' cannot be found" + return false, S("Player '@1' cannot be found.", target_name) end local itemstack = target:get_wielded_item() local can_enchant, errorstring, extra_info = mcl_enchanting.can_enchant(itemstack, enchantment, level) if errorstring == "enchantment invalid" then - return false, "There is no such enchantment '" .. enchantment .. "'" + return false, S("There is no such enchantment '@1'.", enchantment) elseif errorstring == "item missing" then - return false, "The target doesn't hold an item" + return false, S("The target doesn't hold an item.") elseif errorstring == "item not supported" and not mcl_enchanting.is_enchantable(itemstack:get_name()) then - return false, "The target item is not enchantable" + return false, S("The target item is not enchantable.") elseif errorstring == "level invalid" then - return false, "'" .. level_str .. "' is not a valid number" + return false, S("'@1' is not a valid number.", level_str) else target:set_wielded_item(mcl_enchanting.enchant(itemstack, enchantment, level)) - return true, "Enchanting succeded" + return true, S("Enchanting succeded.") end end }) minetest.register_craftitem("mcl_enchanting:book_enchanted", { - description = "Enchanted Book", + description = S("Enchanted Book"), inventory_image = "mcl_enchanting_book_enchanted.png" .. mcl_enchanting.overlay, groups = {enchanted = 1, not_in_creative_inventory = 1, enchantability = 1}, _mcl_enchanting_enchanted_tool = "mcl_enchanting:book_enchanted", @@ -181,7 +182,7 @@ minetest.register_entity("mcl_enchanting:book", { }) minetest.register_node("mcl_enchanting:table", { - description = "Enchanting Table", + description = S("Enchanting Table"), drawtype = "nodebox", tiles = {"mcl_enchanting_table_top.png", "mcl_enchanting_table_bottom.png", "mcl_enchanting_table_side.png", "mcl_enchanting_table_side.png", "mcl_enchanting_table_side.png", "mcl_enchanting_table_side.png"}, node_box = { @@ -197,7 +198,7 @@ minetest.register_node("mcl_enchanting:table", { local num_bookshelves = table_meta:get_int("mcl_enchanting:num_bookshelves") local table_name = table_meta:get_string("name") if table_name == "" then - table_name = "Enchant" + table_name = S("Enchant") end player_meta:set_int("mcl_enchanting:num_bookshelves", num_bookshelves) player_meta:set_string("mcl_enchanting:table_name", table_name)