diff --git a/api.lua b/api.lua index 23dd6d4..1ab19fc 100644 --- a/api.lua +++ b/api.lua @@ -1,3 +1,9 @@ +local S +if intllib then + S = intllib.Getter() +else + S = function(s) return s end +end -- Create detached creative inventory after loading all mods minetest.after(0.01, function() diff --git a/bags.lua b/bags.lua index dce1b3b..10196f5 100644 --- a/bags.lua +++ b/bags.lua @@ -3,11 +3,18 @@ -- Copyright (c) 2012 cornernote, Brett O'Donnell -- License: GPLv3 +local S +if intllib then + S = intllib.Getter() +else + S = function(s) return s end +end + unified_inventory.register_page("bags", { get_formspec = function(player) local player_name = player:get_player_name() local formspec = "background[0.06,0.99;7.92,7.52;ui_bags_main_form.png]" - formspec = formspec.."label[0,0;Bags]" + formspec = formspec.."label[0,0;"..S("Bags").."]" formspec = formspec.."button[0,2;2,0.5;bag1;Bag 1]" formspec = formspec.."button[2,2;2,0.5;bag2;Bag 2]" formspec = formspec.."button[4,2;2,0.5;bag3;Bag 3]" @@ -24,6 +31,7 @@ unified_inventory.register_page("bags", { unified_inventory.register_button("bags", { type = "image", image = "ui_bags_icon.png", + tooltip = S("Bags") }) for i = 1, 4 do @@ -103,19 +111,19 @@ end) -- register bag tools minetest.register_tool("unified_inventory:bag_small", { - description = "Small Bag", + description = S("Small Bag"), inventory_image = "bags_small.png", groups = {bagslots=8}, }) minetest.register_tool("unified_inventory:bag_medium", { - description = "Medium Bag", + description = S("Medium Bag"), inventory_image = "bags_medium.png", groups = {bagslots=16}, }) minetest.register_tool("unified_inventory:bag_large", { - description = "Large Bag", + description = S("Large Bag"), inventory_image = "bags_large.png", groups = {bagslots=24}, }) diff --git a/depends.txt b/depends.txt index 8d390c8..9e4d23a 100644 --- a/depends.txt +++ b/depends.txt @@ -1 +1,2 @@ creative? +intllib? diff --git a/internal.lua b/internal.lua index 4d9c10b..c35bd4c 100644 --- a/internal.lua +++ b/internal.lua @@ -1,3 +1,10 @@ +local S +if intllib then + S = intllib.Getter() +else + S = function(s) return s end +end + -- This pair of encoding functions is used where variable text must go in -- button names, where the text might contain formspec metacharacters. -- We can escape button names for the formspec, to avoid screwing up @@ -36,11 +43,13 @@ function unified_inventory.get_formspec(player, page) -- Main buttons for i, def in pairs(unified_inventory.buttons) do + local tooltip = def.tooltip or "" if def.type == "image" then formspec = formspec.."image_button[" ..(0.65 * (i - 1))..",9;0.8,0.8;" ..minetest.formspec_escape(def.image)..";" - ..minetest.formspec_escape(def.name)..";]" + ..minetest.formspec_escape(def.name)..";;;;;" + ..tooltip.."]" end end diff --git a/locale/de.txt b/locale/de.txt new file mode 100644 index 0000000..a0bd6b0 --- /dev/null +++ b/locale/de.txt @@ -0,0 +1,53 @@ +# Translation by Xanthin + +### bags.lua ### +Bags = Rucksaecke +Bag 1 = Rucksack 1 +Bag 2 = Rucksack 2 +Bag 3 = Rucksack 3 +Bag 4 = Rucksack 4 +Small Bag = Rucksack (klein) +Medium Bag = Rucksack (mittel) +Large Bag = Rucksack (gross) + +### inernal.lua ### +Page: = Seite: +%s of %s = %s von %s +Filter: = Suche: + +### register.lua ### +Can use the creative inventory = Kann das Kreativinventar nutzen +Home position set to: %s = Ausgangsposition nach: %s gesetzt +Time of day set to 6am = Tageszeit auf 6 Uhr morgens geaendert +You don't have the settime priviledge! = Du hast nicht das "settime" Privileg! +Time of day set to 9pm = Tageszeit auf 9 Uhr abends geaendert +This button has been disabled outside of creative mode to prevent accidental inventory trashing. Use the trash slot instead. = Diese Funktion ist ausserhalb des Kreativmodus deaktiviert um ein versehentliches Loeschen des ganzen Inventars zu verhindern. Nutze stattdessen das Muellfeld. +Inventory Cleared! = Inventar geleert! +Crafting = Bauen +Trash: = Muell: +Refill: = Nachfuellen: +Crafting Guide = Bauanleitung +Method: = Methode: +Result: %s = Ergebnis: %s +crafting = Bauen +shapeless crafting = Formloses Bauen +cooking = Kochen +alloy cooking = Legierung Kochen +Copy to craft grid: = Kopiere ins Baufeld: +All = Alles +Recipe %s of %s = Rezept %s von %s +Alternate = Alternative + +### waypoints.lua ### +White = +Yellow = +Red = +Green = +Blue = +Waypoints = +Waypoint active = +Waypoint inactive = +World position = +Name = +HUD text color = +Toggle waypoint = diff --git a/locale/pl.txt b/locale/pl.txt new file mode 100644 index 0000000..867baa4 --- /dev/null +++ b/locale/pl.txt @@ -0,0 +1,53 @@ +# Translation by RealBadAngel + +### bags.lua ### +Bags = Plecaki +Bag 1 = Plecak 1 +Bag 2 = Plecak 2 +Bag 3 = Plecak 3 +Bag 4 = Plecak 4 +Small Bag = Maly plecak +Medium Bag = Sredni plecak +Large Bag = Duzy plecak + +### inernal.lua ### +Page: = +%s of %s = +Filter: = + +### register.lua ### +Can use the creative inventory = +Home position set to: %s = +Time of day set to 6am = +You don't have the settime priviledge! = +Time of day set to 9pm = +This button has been disabled outside of creative mode to prevent accidental inventory trashing. Use the trash slot instead. = +Inventory Cleared! = +Crafting = +Trash: = +Refill: = +Crafting Guide = +Method: = +Result: %s = +crafting = +shapeless crafting = +cooking = +alloy cooking = +Copy to craft grid: = +All = +Recipe %s of %s = +Alternate = + +### waypoints.lua ### +White = Bialy +Yellow = Zolty +Red = Czerwony +Green = Zielony +Blue = Niebieski +Waypoints = Punkty orientacyjne +Waypoint active = Punkt wylaczony +Waypoint inactive = Punkt wlaczony +World position = Pozycja +Name = Nazwa +HUD text color = Kolor tekstu HUD +Toggle waypoint = Przelacz punkt diff --git a/locale/template.txt b/locale/template.txt new file mode 100644 index 0000000..d77a100 --- /dev/null +++ b/locale/template.txt @@ -0,0 +1,54 @@ +# Translation by + +# Template +### bags.lua ### +Bags = +Bag 1 = +Bag 2 = +Bag 3 = +Bag 4 = +Small Bag = +Medium Bag = +Large Bag = + +### inernal.lua ### +Page: = +%s of %s = +Filter: = + +### register.lua ### +Can use the creative inventory = +Home position set to: %s = +Time of day set to 6am = +You don't have the settime priviledge! = +Time of day set to 9pm = +This button has been disabled outside of creative mode to prevent accidental inventory trashing. Use the trash slot instead. = +Inventory Cleared! = +Crafting = +Trash: = +Refill: = +Crafting Guide = +Method: = +Result: %s = +crafting = +shapeless crafting = +cooking = +alloy cooking = +Copy to craft grid: = +All = +Recipe %s of %s = +Alternate = + +### waypoints.lua ### +White = +Yellow = +Red = +Green = +Blue = +Waypoints = +Waypoint active = +Waypoint inactive = +World position = +Name = +HUD text color = +Toggle waypoint = diff --git a/register.lua b/register.lua index 1c8eb54..9be3dbe 100644 --- a/register.lua +++ b/register.lua @@ -1,3 +1,9 @@ +local S +if intllib then + S = intllib.Getter() +else + S = function(s) return s end +end minetest.register_privilege("creative", { description = "Can use the creative inventory", @@ -23,16 +29,19 @@ trash:set_size("main", 1) unified_inventory.register_button("craft", { type = "image", image = "ui_craft_icon.png", + tooltip = S("Crafting Menu") }) unified_inventory.register_button("craftguide", { type = "image", image = "ui_craftguide_icon.png", + tooltip = S("Crafting Guide") }) unified_inventory.register_button("home_gui_set", { type = "image", image = "ui_sethome_icon.png", + tooltip = S("Set home position"), action = function(player) local player_name = player:get_player_name() unified_inventory.set_home(player, player:getpos()) @@ -50,6 +59,7 @@ unified_inventory.register_button("home_gui_set", { unified_inventory.register_button("home_gui_go", { type = "image", image = "ui_gohome_icon.png", + tooltip = S("Go home"), action = function(player) minetest.sound_play("teleport", {to_player=player:get_player_name(), gain = 1.0}) @@ -60,6 +70,7 @@ unified_inventory.register_button("home_gui_go", { unified_inventory.register_button("misc_set_day", { type = "image", image = "ui_sun_icon.png", + tooltip = S("Set time to day"), action = function(player) local player_name = player:get_player_name() if minetest.check_player_privs(player_name, {settime=true}) then @@ -79,6 +90,7 @@ unified_inventory.register_button("misc_set_day", { unified_inventory.register_button("misc_set_night", { type = "image", image = "ui_moon_icon.png", + tooltip = S("Set time to night"), action = function(player) local player_name = player:get_player_name() if minetest.check_player_privs(player_name, {settime=true}) then @@ -98,6 +110,7 @@ unified_inventory.register_button("misc_set_night", { unified_inventory.register_button("clear_inv", { type = "image", image = "ui_trash_icon.png", + tooltip = S("Clear inventory"), action = function(player) local player_name = player:get_player_name() if not unified_inventory.is_creative(player_name) then diff --git a/waypoints.lua b/waypoints.lua index 55e91a4..f37abda 100644 --- a/waypoints.lua +++ b/waypoints.lua @@ -1,9 +1,16 @@ +local S +if intllib then + S = intllib.Getter() +else + S = function(s) return s end +end + unified_inventory.hud_colors = { - {"#FFFFFF", 0xFFFFFF, "White"}, - {"#DBBB00", 0xf1d32c, "Yellow"}, - {"#DD0000", 0xDD0000, "Red"}, - {"#2cf136", 0x2cf136, "Green"}, - {"#2c4df1", 0x2c4df1, "Blue"}, + {"#FFFFFF", 0xFFFFFF, S("White")}, + {"#DBBB00", 0xf1d32c, S("Yellow")}, + {"#DD0000", 0xDD0000, S("Red")}, + {"#2cf136", 0x2cf136, S("Green")}, + {"#2c4df1", 0x2c4df1, S("Blue")}, } unified_inventory.hud_colors_max = #unified_inventory.hud_colors @@ -12,7 +19,7 @@ unified_inventory.register_page("waypoints", { local waypoints = datastorage.get_container (player, "waypoints") local formspec = "background[0,4.5;8,4;ui_main_inventory.png]".. "image[0,0;1,1;ui_waypoints_icon.png]".. - "label[1,0;Waypoints]" + "label[1,0;"..S("Waypoints").."]" -- Tabs buttons: local i @@ -36,10 +43,10 @@ unified_inventory.register_page("waypoints", { if waypoints[i].active then formspec = formspec .. - "image_button[5.2,3.7;.8,.8;ui_on_icon.png;toggle_waypoint".. i .. ";]" + "image_button[5.2,3.7;.8,.8;ui_on_icon.png;toggle_waypoint".. i .. ";;;;;"..S("Toggle waypoint").."]" else formspec = formspec .. - "image_button[5.2,3.7;.8,.8;ui_off_icon.png;toggle_waypoint".. i .. ";]" + "image_button[5.2,3.7;.8,.8;ui_off_icon.png;toggle_waypoint".. i .. ";;;;;"..S("Toggle waypoint").."]" end if waypoints[i].display_pos then @@ -56,9 +63,9 @@ unified_inventory.register_page("waypoints", { -- Waypoint's info: if waypoints[i].active then - formspec = formspec .. "label[1,0.8;Waypoint active]" + formspec = formspec .. "label[1,0.8;"..S("Waypoint active").."]" else - formspec = formspec .. "label[1,0.8;Waypoint inactive]" + formspec = formspec .. "label[1,0.8;"..S("Waypoint inactive").."]" end if waypoints[i].edit then @@ -67,10 +74,10 @@ unified_inventory.register_page("waypoints", { "image_button[7.3,2.9;.8,.8;ui_ok_icon.png;confirm_rename".. i .. ";]" end - formspec = formspec .. "label[1,1.3;World position: " .. + formspec = formspec .. "label[1,1.3;"..S("World position")..": " .. minetest.pos_to_string(waypoints[i].world_pos) .. "]" .. - "label[1,1.8;Name: ".. waypoints[i].name .. "]" .. - "label[1,2.3;Hud text color: " .. + "label[1,1.8;"..S("Name")..": ".. waypoints[i].name .. "]" .. + "label[1,2.3;"..S("HUD text color")..": " .. unified_inventory.hud_colors[waypoints[i].color][3] .. "]" return {formspec=formspec}