Add intllib support.

Some polish and german translations.
Start adding tooltips.
This commit is contained in:
RealBadAngel 2014-06-21 12:44:31 +02:00
parent 87f502a259
commit 002bcbb6d8
9 changed files with 222 additions and 18 deletions

View File

@ -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 -- Create detached creative inventory after loading all mods
minetest.after(0.01, function() minetest.after(0.01, function()

View File

@ -3,11 +3,18 @@
-- Copyright (c) 2012 cornernote, Brett O'Donnell <cornernote@gmail.com> -- Copyright (c) 2012 cornernote, Brett O'Donnell <cornernote@gmail.com>
-- License: GPLv3 -- License: GPLv3
local S
if intllib then
S = intllib.Getter()
else
S = function(s) return s end
end
unified_inventory.register_page("bags", { unified_inventory.register_page("bags", {
get_formspec = function(player) get_formspec = function(player)
local player_name = player:get_player_name() local player_name = player:get_player_name()
local formspec = "background[0.06,0.99;7.92,7.52;ui_bags_main_form.png]" 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[0,2;2,0.5;bag1;Bag 1]"
formspec = formspec.."button[2,2;2,0.5;bag2;Bag 2]" formspec = formspec.."button[2,2;2,0.5;bag2;Bag 2]"
formspec = formspec.."button[4,2;2,0.5;bag3;Bag 3]" 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", { unified_inventory.register_button("bags", {
type = "image", type = "image",
image = "ui_bags_icon.png", image = "ui_bags_icon.png",
tooltip = S("Bags")
}) })
for i = 1, 4 do for i = 1, 4 do
@ -103,19 +111,19 @@ end)
-- register bag tools -- register bag tools
minetest.register_tool("unified_inventory:bag_small", { minetest.register_tool("unified_inventory:bag_small", {
description = "Small Bag", description = S("Small Bag"),
inventory_image = "bags_small.png", inventory_image = "bags_small.png",
groups = {bagslots=8}, groups = {bagslots=8},
}) })
minetest.register_tool("unified_inventory:bag_medium", { minetest.register_tool("unified_inventory:bag_medium", {
description = "Medium Bag", description = S("Medium Bag"),
inventory_image = "bags_medium.png", inventory_image = "bags_medium.png",
groups = {bagslots=16}, groups = {bagslots=16},
}) })
minetest.register_tool("unified_inventory:bag_large", { minetest.register_tool("unified_inventory:bag_large", {
description = "Large Bag", description = S("Large Bag"),
inventory_image = "bags_large.png", inventory_image = "bags_large.png",
groups = {bagslots=24}, groups = {bagslots=24},
}) })

View File

@ -1 +1,2 @@
creative? creative?
intllib?

View File

@ -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 -- This pair of encoding functions is used where variable text must go in
-- button names, where the text might contain formspec metacharacters. -- button names, where the text might contain formspec metacharacters.
-- We can escape button names for the formspec, to avoid screwing up -- 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 -- Main buttons
for i, def in pairs(unified_inventory.buttons) do for i, def in pairs(unified_inventory.buttons) do
local tooltip = def.tooltip or ""
if def.type == "image" then if def.type == "image" then
formspec = formspec.."image_button[" formspec = formspec.."image_button["
..(0.65 * (i - 1))..",9;0.8,0.8;" ..(0.65 * (i - 1))..",9;0.8,0.8;"
..minetest.formspec_escape(def.image)..";" ..minetest.formspec_escape(def.image)..";"
..minetest.formspec_escape(def.name)..";]" ..minetest.formspec_escape(def.name)..";;;;;"
..tooltip.."]"
end end
end end

53
locale/de.txt Normal file
View File

@ -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 =

53
locale/pl.txt Normal file
View File

@ -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

54
locale/template.txt Normal file
View File

@ -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 =

View File

@ -1,3 +1,9 @@
local S
if intllib then
S = intllib.Getter()
else
S = function(s) return s end
end
minetest.register_privilege("creative", { minetest.register_privilege("creative", {
description = "Can use the creative inventory", description = "Can use the creative inventory",
@ -23,16 +29,19 @@ trash:set_size("main", 1)
unified_inventory.register_button("craft", { unified_inventory.register_button("craft", {
type = "image", type = "image",
image = "ui_craft_icon.png", image = "ui_craft_icon.png",
tooltip = S("Crafting Menu")
}) })
unified_inventory.register_button("craftguide", { unified_inventory.register_button("craftguide", {
type = "image", type = "image",
image = "ui_craftguide_icon.png", image = "ui_craftguide_icon.png",
tooltip = S("Crafting Guide")
}) })
unified_inventory.register_button("home_gui_set", { unified_inventory.register_button("home_gui_set", {
type = "image", type = "image",
image = "ui_sethome_icon.png", image = "ui_sethome_icon.png",
tooltip = S("Set home position"),
action = function(player) action = function(player)
local player_name = player:get_player_name() local player_name = player:get_player_name()
unified_inventory.set_home(player, player:getpos()) 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", { unified_inventory.register_button("home_gui_go", {
type = "image", type = "image",
image = "ui_gohome_icon.png", image = "ui_gohome_icon.png",
tooltip = S("Go home"),
action = function(player) action = function(player)
minetest.sound_play("teleport", minetest.sound_play("teleport",
{to_player=player:get_player_name(), gain = 1.0}) {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", { unified_inventory.register_button("misc_set_day", {
type = "image", type = "image",
image = "ui_sun_icon.png", image = "ui_sun_icon.png",
tooltip = S("Set time to day"),
action = function(player) action = function(player)
local player_name = player:get_player_name() local player_name = player:get_player_name()
if minetest.check_player_privs(player_name, {settime=true}) then 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", { unified_inventory.register_button("misc_set_night", {
type = "image", type = "image",
image = "ui_moon_icon.png", image = "ui_moon_icon.png",
tooltip = S("Set time to night"),
action = function(player) action = function(player)
local player_name = player:get_player_name() local player_name = player:get_player_name()
if minetest.check_player_privs(player_name, {settime=true}) then 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", { unified_inventory.register_button("clear_inv", {
type = "image", type = "image",
image = "ui_trash_icon.png", image = "ui_trash_icon.png",
tooltip = S("Clear inventory"),
action = function(player) action = function(player)
local player_name = player:get_player_name() local player_name = player:get_player_name()
if not unified_inventory.is_creative(player_name) then if not unified_inventory.is_creative(player_name) then

View File

@ -1,9 +1,16 @@
local S
if intllib then
S = intllib.Getter()
else
S = function(s) return s end
end
unified_inventory.hud_colors = { unified_inventory.hud_colors = {
{"#FFFFFF", 0xFFFFFF, "White"}, {"#FFFFFF", 0xFFFFFF, S("White")},
{"#DBBB00", 0xf1d32c, "Yellow"}, {"#DBBB00", 0xf1d32c, S("Yellow")},
{"#DD0000", 0xDD0000, "Red"}, {"#DD0000", 0xDD0000, S("Red")},
{"#2cf136", 0x2cf136, "Green"}, {"#2cf136", 0x2cf136, S("Green")},
{"#2c4df1", 0x2c4df1, "Blue"}, {"#2c4df1", 0x2c4df1, S("Blue")},
} }
unified_inventory.hud_colors_max = #unified_inventory.hud_colors 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 waypoints = datastorage.get_container (player, "waypoints")
local formspec = "background[0,4.5;8,4;ui_main_inventory.png]".. local formspec = "background[0,4.5;8,4;ui_main_inventory.png]"..
"image[0,0;1,1;ui_waypoints_icon.png]".. "image[0,0;1,1;ui_waypoints_icon.png]"..
"label[1,0;Waypoints]" "label[1,0;"..S("Waypoints").."]"
-- Tabs buttons: -- Tabs buttons:
local i local i
@ -36,10 +43,10 @@ unified_inventory.register_page("waypoints", {
if waypoints[i].active then if waypoints[i].active then
formspec = formspec .. 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 else
formspec = formspec .. 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 end
if waypoints[i].display_pos then if waypoints[i].display_pos then
@ -56,9 +63,9 @@ unified_inventory.register_page("waypoints", {
-- Waypoint's info: -- Waypoint's info:
if waypoints[i].active then if waypoints[i].active then
formspec = formspec .. "label[1,0.8;Waypoint active]" formspec = formspec .. "label[1,0.8;"..S("Waypoint active").."]"
else else
formspec = formspec .. "label[1,0.8;Waypoint inactive]" formspec = formspec .. "label[1,0.8;"..S("Waypoint inactive").."]"
end end
if waypoints[i].edit then 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 .. ";]" "image_button[7.3,2.9;.8,.8;ui_ok_icon.png;confirm_rename".. i .. ";]"
end 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) .. "]" .. minetest.pos_to_string(waypoints[i].world_pos) .. "]" ..
"label[1,1.8;Name: ".. waypoints[i].name .. "]" .. "label[1,1.8;"..S("Name")..": ".. waypoints[i].name .. "]" ..
"label[1,2.3;Hud text color: " .. "label[1,2.3;"..S("HUD text color")..": " ..
unified_inventory.hud_colors[waypoints[i].color][3] .. "]" unified_inventory.hud_colors[waypoints[i].color][3] .. "]"
return {formspec=formspec} return {formspec=formspec}