From 0d6610dcee4fd12231cd244b78ed7340719043b6 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Thu, 7 Mar 2019 21:10:39 +0100 Subject: [PATCH] New translation system, part 3: HUD --- mods/HUD/awards/api.lua | 5 +- mods/HUD/awards/chat_commands.lua | 7 +- mods/HUD/awards/depends.txt | 1 - mods/HUD/awards/init.lua | 9 -- mods/HUD/awards/sfinv.lua | 7 +- mods/HUD/awards/triggers.lua | 7 +- mods/HUD/awards/unified_inventory.lua | 7 +- mods/HUD/mcl_achievements/depends.txt | 1 - mods/HUD/mcl_achievements/init.lua | 7 +- mods/HUD/mcl_death_messages/init.lua | 132 +++++++++++++------------- mods/HUD/mcl_inventory/creative.lua | 37 ++++---- mods/HUD/mcl_inventory/init.lua | 11 ++- 12 files changed, 100 insertions(+), 131 deletions(-) diff --git a/mods/HUD/awards/api.lua b/mods/HUD/awards/api.lua index 09f92917..d377f37c 100644 --- a/mods/HUD/awards/api.lua +++ b/mods/HUD/awards/api.lua @@ -29,10 +29,7 @@ function awards.save() end end -local S = function(s) return s end -function awards.set_intllib(locale) - S = locale -end +local S = minetest.get_translator("awards") function awards.init() awards.players = awards.load() diff --git a/mods/HUD/awards/chat_commands.lua b/mods/HUD/awards/chat_commands.lua index c386c19c..6571267d 100644 --- a/mods/HUD/awards/chat_commands.lua +++ b/mods/HUD/awards/chat_commands.lua @@ -14,12 +14,7 @@ -- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -- -local S -if minetest.get_modpath("intllib") then - S = intllib.Getter() -else - S = function ( s ) return s end -end +local S = minetest.get_translator("awards") minetest.register_chatcommand("awards", { params = S("[c|clear|disable|enable]"), diff --git a/mods/HUD/awards/depends.txt b/mods/HUD/awards/depends.txt index cffd9473..80a448a4 100644 --- a/mods/HUD/awards/depends.txt +++ b/mods/HUD/awards/depends.txt @@ -1,3 +1,2 @@ -intllib? sfinv? unified_inventory? diff --git a/mods/HUD/awards/init.lua b/mods/HUD/awards/init.lua index acf8bfdc..63c9303c 100644 --- a/mods/HUD/awards/init.lua +++ b/mods/HUD/awards/init.lua @@ -14,18 +14,9 @@ -- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -- - -local S -if minetest.get_modpath("intllib") then - S = intllib.Getter() -else - S = function ( s ) return s end -end - dofile(minetest.get_modpath("awards").."/api.lua") dofile(minetest.get_modpath("awards").."/chat_commands.lua") dofile(minetest.get_modpath("awards").."/sfinv.lua") dofile(minetest.get_modpath("awards").."/unified_inventory.lua") dofile(minetest.get_modpath("awards").."/triggers.lua") -awards.set_intllib(S) diff --git a/mods/HUD/awards/sfinv.lua b/mods/HUD/awards/sfinv.lua index de85998c..5d02cbb5 100644 --- a/mods/HUD/awards/sfinv.lua +++ b/mods/HUD/awards/sfinv.lua @@ -1,10 +1,5 @@ if minetest.get_modpath("sfinv") then - local S - if minetest.get_modpath("intllib") then - S = intllib.Getter() - else - S = function ( s ) return s end - end + local S = minetest.get_translator("awards") sfinv.register_page("awards:awards", { title = S("Awards"), diff --git a/mods/HUD/awards/triggers.lua b/mods/HUD/awards/triggers.lua index 88a952fd..42e126bd 100644 --- a/mods/HUD/awards/triggers.lua +++ b/mods/HUD/awards/triggers.lua @@ -14,12 +14,7 @@ -- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -- -local S -if minetest.get_modpath("intllib") then - S = intllib.Getter() -else - S = function ( s ) return s end -end +local S = minetest.get_translator("awards") awards.register_trigger("dig", function(def) local tmp = { diff --git a/mods/HUD/awards/unified_inventory.lua b/mods/HUD/awards/unified_inventory.lua index a4bb02dc..be5ca5f9 100644 --- a/mods/HUD/awards/unified_inventory.lua +++ b/mods/HUD/awards/unified_inventory.lua @@ -1,10 +1,5 @@ if minetest.get_modpath("unified_inventory") ~= nil then - local S - if minetest.get_modpath("intllib") then - S = intllib.Getter() - else - S = function ( s ) return s end - end + local S = minetest.get_translator("awards") unified_inventory.register_button("awards", { type = "image", diff --git a/mods/HUD/mcl_achievements/depends.txt b/mods/HUD/mcl_achievements/depends.txt index 1679faeb..203a4c0a 100644 --- a/mods/HUD/mcl_achievements/depends.txt +++ b/mods/HUD/mcl_achievements/depends.txt @@ -1,2 +1 @@ awards -intllib? diff --git a/mods/HUD/mcl_achievements/init.lua b/mods/HUD/mcl_achievements/init.lua index fed23ee3..cfeea18b 100644 --- a/mods/HUD/mcl_achievements/init.lua +++ b/mods/HUD/mcl_achievements/init.lua @@ -3,12 +3,7 @@ -- If true, activates achievements from other Minecraft editions (XBox, PS, etc.) local non_pc_achievements = false -local S -if minetest.get_modpath("intllib") then - S = intllib.Getter() -else - S = function ( s ) return s end -end +local S = minetest.get_translator("mcl_achievements") -- Achievements from PC Edition diff --git a/mods/HUD/mcl_death_messages/init.lua b/mods/HUD/mcl_death_messages/init.lua index 00f39ac4..302b1a67 100644 --- a/mods/HUD/mcl_death_messages/init.lua +++ b/mods/HUD/mcl_death_messages/init.lua @@ -1,101 +1,103 @@ +local S = minetest.get_translator("mcl_death_messages") + mcl_death_messages = {} -- Death messages local msgs = { ["arrow"] = { - "%s was fatally hit by an arrow.", - "%s has been killed with an arrow.", + S("%s was fatally hit by an arrow."), + S("%s has been killed with an arrow."), }, ["arrow_name"] = { - "%s was shot by an arrow from %s.", + S("%s was shot by an arrow from %s."), }, ["fire"] = { - "%s has been cooked crisp.", - "%s felt the burn.", - "%s died in the flames.", - "%s died in a fire.", + S("%s has been cooked crisp."), + S("%s felt the burn."), + S("%s died in the flames."), + S("%s died in a fire."), }, ["lava"] = { - "%s melted in lava.", - "%s took a bath in a hot lava tub.", - "%s died in lava.", - "%s could not survive in lava.", + S("%s melted in lava."), + S("%s took a bath in a hot lava tub."), + S("%s died in lava."), + S("%s could not survive in lava."), }, ["drown"] = { - "%s forgot to breathe.", - "%s drowned.", - "%s ran out of oxygen.", + S("%s forgot to breathe."), + S("%s drowned."), + S("%s ran out of oxygen."), }, ["starve"] = { - "%s starved.", + S("%s starved."), }, ["murder"] = { - "%s was killed by %s.", + S("%s was killed by %s."), }, ["mob_kill"] = { - "%s was killed by a mob.", + S("%s was killed by a mob."), }, ["blaze_fireball"] = { - "%s was burned to death by a blaze's fireball.", - "%s was killed by a fireball from a blaze.", + S("%s was burned to death by a blaze's fireball."), + S("%s was killed by a fireball from a blaze."), }, ["fire_charge"] = { - "%s was hit by a fire charge.", + S("%s was hit by a fire charge."), }, ["ghast_fireball"] = { - "A ghast scared %s to death.", - "%s has been fireballed by a ghast.", + S("A ghast scared %s to death."), + S("%s has been fireballed by a ghast."), }, ["fall_damage"] = { - "%s fell from a high cliff.", - "%s took fatal fall damage.", - "%s fell victim to gravity.", + S("%s fell from a high cliff."), + S("%s took fatal fall damage."), + S("%s fell victim to gravity."), }, ["other"] = { - "%s died.", + S("%s died."), } } local mobkills = { - ["mobs_mc:zombie"] = "%s was killed by a zombie.", - ["mobs_mc:baby_zombie"] = "%s was killed by a baby zombie.", - ["mobs_mc:blaze"] = "%s was killed by a blaze.", - ["mobs_mc:slime"] = "%s was killed by a slime.", - ["mobs_mc:witch"] = "%s was killed by a witch.", - ["mobs_mc:magma_cube_tiny"] = "%s was killed by a magma cube.", - ["mobs_mc:magma_cube_small"] = "%s was killed by a magma cube.", - ["mobs_mc:magma_cube_big"] = "%s was killed by a magma cube.", - ["mobs_mc:wolf"] = "%s was killed by a wolf.", - ["mobs_mc:cat"] = "%s was killed by a cat.", - ["mobs_mc:ocelot"] = "%s was killed by an ocelot.", - ["mobs_mc:ender_dragon"] = "%s was killed by an ender dragon.", - ["mobs_mc:wither"] = "%s was killed by a wither.", - ["mobs_mc:enderman"] = "%s was killed by an enderman.", - ["mobs_mc:endermite"] = "%s was killed by an endermite.", - ["mobs_mc:ghast"] = "%s was killed by a ghast.", - ["mobs_mc:guardian_elder"] = "%s was killed by an elder guardian.", - ["mobs_mc:guardian"] = "%s was killed by a guardian.", - ["mobs_mc:iron_golem"] = "%s was killed by an iron golem.", - ["mobs_mc:polar_bear"] = "%s was killed by a polar_bear.", - ["mobs_mc:killer_bunny"] = "%s was killed by a killer bunny.", - ["mobs_mc:shulker"] = "%s was killed by a shulker.", - ["mobs_mc:silverfish"] = "%s was killed by a silverfish.", - ["mobs_mc:skeleton"] = "%s was killed by a skeleton.", - ["mobs_mc:stray"] = "%s was killed by a stray.", - ["mobs_mc:slime_tiny"] = "%s was killed by a slime.", - ["mobs_mc:slime_small"] = "%s was killed by a slime.", - ["mobs_mc:slime_big"] = "%s was killed by a slime.", - ["mobs_mc:spider"] = "%s was killed by a spider.", - ["mobs_mc:cave_spider"] = "%s was killed by a cave spider.", - ["mobs_mc:vex"] = "%s was killed by a vex.", - ["mobs_mc:evoker"] = "%s was killed by an evoker.", - ["mobs_mc:illusioner"] = "%s was killed by an illusioner.", - ["mobs_mc:vindicator"] = "%s was killed by a vindicator.", - ["mobs_mc:villager_zombie"] = "%s was killed by a zombie villager.", - ["mobs_mc:husk"] = "%s was killed by a husk.", - ["mobs_mc:baby_husk"] = "%s was killed by a baby husk.", - ["mobs_mc:pigman"] = "%s was killed by a zombie pigman.", - ["mobs_mc:baby_pigman"] = "%s was killed by a baby zombie pigman.", + ["mobs_mc:zombie"] = S("%s was killed by a zombie."), + ["mobs_mc:baby_zombie"] = S("%s was killed by a baby zombie."), + ["mobs_mc:blaze"] = S("%s was killed by a blaze."), + ["mobs_mc:slime"] = S("%s was killed by a slime."), + ["mobs_mc:witch"] = S("%s was killed by a witch."), + ["mobs_mc:magma_cube_tiny"] = S("%s was killed by a magma cube."), + ["mobs_mc:magma_cube_small"] = S("%s was killed by a magma cube."), + ["mobs_mc:magma_cube_big"] = S("%s was killed by a magma cube."), + ["mobs_mc:wolf"] = S("%s was killed by a wolf."), + ["mobs_mc:cat"] = S("%s was killed by a cat."), + ["mobs_mc:ocelot"] = S("%s was killed by an ocelot."), + ["mobs_mc:ender_dragon"] = S("%s was killed by an ender dragon."), + ["mobs_mc:wither"] = S("%s was killed by a wither."), + ["mobs_mc:enderman"] = S("%s was killed by an enderman."), + ["mobs_mc:endermite"] = S("%s was killed by an endermite."), + ["mobs_mc:ghast"] = S("%s was killed by a ghast."), + ["mobs_mc:guardian_elder"] = S("%s was killed by an elder guardian."), + ["mobs_mc:guardian"] = S("%s was killed by a guardian."), + ["mobs_mc:iron_golem"] = S("%s was killed by an iron golem."), + ["mobs_mc:polar_bear"] = S("%s was killed by a polar_bear."), + ["mobs_mc:killer_bunny"] = S("%s was killed by a killer bunny."), + ["mobs_mc:shulker"] = S("%s was killed by a shulker."), + ["mobs_mc:silverfish"] = S("%s was killed by a silverfish."), + ["mobs_mc:skeleton"] = S("%s was killed by a skeleton."), + ["mobs_mc:stray"] = S("%s was killed by a stray."), + ["mobs_mc:slime_tiny"] = S("%s was killed by a slime."), + ["mobs_mc:slime_small"] = S("%s was killed by a slime."), + ["mobs_mc:slime_big"] = S("%s was killed by a slime."), + ["mobs_mc:spider"] = S("%s was killed by a spider."), + ["mobs_mc:cave_spider"] = S("%s was killed by a cave spider."), + ["mobs_mc:vex"] = S("%s was killed by a vex."), + ["mobs_mc:evoker"] = S("%s was killed by an evoker."), + ["mobs_mc:illusioner"] = S("%s was killed by an illusioner."), + ["mobs_mc:vindicator"] = S("%s was killed by a vindicator."), + ["mobs_mc:villager_zombie"] = S("%s was killed by a zombie villager."), + ["mobs_mc:husk"] = S("%s was killed by a husk."), + ["mobs_mc:baby_husk"] = S("%s was killed by a baby husk."), + ["mobs_mc:pigman"] = S("%s was killed by a zombie pigman."), + ["mobs_mc:baby_pigman"] = S("%s was killed by a baby zombie pigman."), } -- Select death message diff --git a/mods/HUD/mcl_inventory/creative.lua b/mods/HUD/mcl_inventory/creative.lua index 536cc56a..2637ac28 100644 --- a/mods/HUD/mcl_inventory/creative.lua +++ b/mods/HUD/mcl_inventory/creative.lua @@ -1,3 +1,6 @@ +local S = minetest.get_translator("mcl_inventory") +local F = function(s) return minetest.formspec_escape(S(s)) end + -- Prepare player info table local players = {} @@ -320,16 +323,16 @@ mcl_inventory.set_creative_formspec = function(player, start_i, pagenum, inv_siz player_preview.. -- crafting guide button "image_button[9,1;1,1;craftguide_book.png;__mcl_craftguide;]".. - "tooltip[__mcl_craftguide;Recipe book]".. + "tooltip[__mcl_craftguide;"..F("Recipe book")"..]".. -- help button "image_button[9,2;1,1;doc_button_icon_lores.png;__mcl_doc;]".. - "tooltip[__mcl_doc;Help]".. + "tooltip[__mcl_doc;"..F("Help").."]".. -- skins button "image_button[9,3;1,1;mcl_skins_button.png;__mcl_skins;]".. - "tooltip[__mcl_skins;Select player skin]".. + "tooltip[__mcl_skins;"..F("Select player skin").."]".. -- achievements button "image_button[9,4;1,1;mcl_achievements_button.png;__mcl_achievements;]".. - "tooltip[__mcl_achievements;Achievements]" + "tooltip[__mcl_achievements;"..F("Achievements").."]" -- For shortcuts listrings = listrings .. @@ -382,35 +385,35 @@ mcl_inventory.set_creative_formspec = function(player, start_i, pagenum, inv_siz "background[-0.19,-0.25;10.5,9.87;"..inv_bg.."]".. "label[-5,-5;"..name.."]".. tab(name, "blocks") .. - "tooltip[blocks;Building Blocks]".. + "tooltip[blocks;"..F("Building Blocks").."]".. tab(name, "deco") .. - "tooltip[deco;Decoration Blocks]".. + "tooltip[deco;"..F("Decoration Blocks").."]".. tab(name, "redstone") .. - "tooltip[redstone;Redstone]".. + "tooltip[redstone;"..F("Redstone").."]".. tab(name, "rail") .. - "tooltip[rail;Transportation]".. + "tooltip[rail;"..F("Transportation").."]".. tab(name, "misc") .. - "tooltip[misc;Miscellaneous]".. + "tooltip[misc;"..F("Miscellaneous").."]".. tab(name, "nix") .. - "tooltip[nix;Search Items]".. + "tooltip[nix;"..F("Search Items").."]".. fnt.. "list[current_player;main;0,7;9,1;]".. main_list.. tab(name, "food") .. - "tooltip[food;Foodstuffs]".. + "tooltip[food;"..F("Foodstuffs").."]".. tab(name, "tools") .. - "tooltip[tools;Tools]".. + "tooltip[tools;"..F("Tools").."]".. tab(name, "combat") .. - "tooltip[combat;Combat]".. + "tooltip[combat;"..F("Combat").."]".. tab(name, "mobs") .. - "tooltip[mobs;Mobs]".. + "tooltip[mobs;"..F("Mobs").."]".. -- TODO: Add brew --tab(name, "brew") .. - --"tooltip[brew;Brewing]".. + --"tooltip[brew;"..F("Brewing").."]".. tab(name, "matr") .. - "tooltip[matr;Materials]".. + "tooltip[matr;"..F("Materials").."]".. tab(name, "inv") .. - "tooltip[inv;Survival Inventory]".. + "tooltip[inv;"..F("Survival Inventory").."]".. "list[detached:trash;main;9,7;1,1;]".. "image[9,7;1,1;crafting_creative_trash.png]".. listrings diff --git a/mods/HUD/mcl_inventory/init.lua b/mods/HUD/mcl_inventory/init.lua index bed3c485..899abeba 100644 --- a/mods/HUD/mcl_inventory/init.lua +++ b/mods/HUD/mcl_inventory/init.lua @@ -1,3 +1,6 @@ +local S = minetest.get_translator("mcl_inventory") +local F = function(s) return minetest.formspec_escape(S(s)) end + mcl_inventory = {} local show_armor = minetest.get_modpath("3d_armor") ~= nil @@ -101,16 +104,16 @@ local function set_inventory(player, armor_change_only) "list[current_player;craftpreview;7,1.5;1,1;]".. -- crafting guide button "image_button[4.5,3;1,1;craftguide_book.png;__mcl_craftguide;]".. - "tooltip[__mcl_craftguide;Recipe book]".. + "tooltip[__mcl_craftguide;"..F("Recipe book").."]".. -- help button "image_button[8,3;1,1;doc_button_icon_lores.png;__mcl_doc;]".. - "tooltip[__mcl_doc;Help]".. + "tooltip[__mcl_doc;"..F("Help").."]".. -- skins button "image_button[3,3;1,1;mcl_skins_button.png;__mcl_skins;]".. - "tooltip[__mcl_skins;Select player skin]".. + "tooltip[__mcl_skins;"..F("Select player skin").."]".. -- achievements button "image_button[7,3;1,1;mcl_achievements_button.png;__mcl_achievements;]".. - "tooltip[__mcl_achievements;Achievements]".. + "tooltip[__mcl_achievements;"..F("Achievements").."]".. -- for shortcuts "listring[current_player;main]".. "listring[current_player;craft]"..