Added intllib support

This commit is contained in:
TeTpaAka 2015-03-03 22:04:01 +01:00
parent 25a89f844d
commit 5f481f7a74
6 changed files with 74 additions and 15 deletions

View File

@ -1,3 +1,12 @@
-- Boilerplate to support localized strings if intllib mod is installed.
local S
if minetest.get_modpath("intllib") then
S = intllib.Getter()
else
-- If you don't use insertions (@1, @2, etc) you can use this:
S = function(s) return s end
end
-- registers a quest for later use
--
@ -19,8 +28,8 @@ function quests.register_quest(questname, quest)
return false -- The quest was not registered since there already a quest with that name
end
quests.registered_quests[questname] =
{ title = quest.title or "missing title",
description = quest.description or "missing description",
{ title = quest.title or S("missing title"),
description = quest.description or S("missing description"),
max = quest.max or 1,
autoaccept = quest.autoaccept or false,
callback = quest.callback, }

View File

@ -0,0 +1 @@
intllib?

View File

@ -1,3 +1,13 @@
-- Boilerplate to support localized strings if intllib mod is installed.
local S
if minetest.get_modpath("intllib") then
S = intllib.Getter()
else
-- If you don't use insertions (@1, @2, etc) you can use this:
S = function(s) return s end
end
-- construct the questlog
function quests.create_formspec(playername, tab)
local queststringlist = {}
@ -30,32 +40,32 @@ function quests.create_formspec(playername, tab)
end
end
local formspec = "size[7,10]"..
"tabheader[0,0;header;Open quests,Finished quests,Failed quests;" .. tab .. "]"
"tabheader[0,0;header;" .. S("Open quests") .. "," .. S("Finished quests") .. "," .. S("Failed quests") .. ";" .. tab .. "]"
if (no_quests) then
formspec = formspec .. "label[0.25,0.25;There are no quests in this category.]"
formspec = formspec .. "label[0.25,0.25;" .. S("There are no quests in this category.") .. "]"
else
formspec = formspec .. "textlist[0.25,0.25;6.5,7.5;questlist;"..table.concat(queststringlist, ",") .. ";1;false]"
end
if (quests.formspec_lists[playername].tab == "1") then
formspec = formspec .."button[0.25,8;3,.7;abort;Abort quest]"
formspec = formspec .."button[0.25,8;3,.7;abort;" .. S("Abort quest") .. "]"
end
formspec = formspec .. "button[3.75,8;3,.7;config;Configure]"..
"button[.25,9;3,.7;info;Info]"..
"button_exit[3.75,9;3,.7;exit;Exit]"
formspec = formspec .. "button[3.75,8;3,.7;config;" .. S("Configure") .. "]"..
"button[.25,9;3,.7;info;" .. S("Info") .. "]"..
"button_exit[3.75,9;3,.7;exit;" .. S("Exit") .. "]"
return formspec
end
-- construct the configuration
function quests.create_config(playername)
local formspec = "size[7,3]" ..
"checkbox[.25,.25;enable;Enable HUD;"
"checkbox[.25,.25;enable;" .. S("Enable HUD") .. ";"
if(quests.hud[playername] ~= nil) then
formspec = formspec .. "true"
else
formspec = formspec .. "false"
end
formspec = formspec .. "]"..
"button[.25,1.25;3,.7;return;Return]"
"button[.25,1.25;3,.7;return;" .. S("Return") .. "]"
return formspec
end
@ -69,12 +79,12 @@ function quests.create_info(playername, questname)
"textarea[.5,1.5;6,4.5;description;;" .. quests.registered_quests[questname].description .. "]"
if (quests.formspec_lists[playername].tab == "1") then
formspec = formspec .. "button[.5,6;3,.7;abort;Abort quest]"
formspec = formspec .. "button[.5,6;3,.7;abort;" .. S("Abort quest") .. "]"
end
else
formspec = formspec .. "No quest specified.]"
formspec = formspec .. S("No quest specified.") .. "]"
end
formspec = formspec .. "button[3.25,6;3,.7;return;Return]"
formspec = formspec .. "button[3.25,6;3,.7;return;" .. S("Return") .. "]"
return formspec
end
@ -86,7 +96,7 @@ end
-- chatcommand to see a full list of quests:
minetest.register_chatcommand("quests", {
params = "",
description = "Show all open quests",
description = S("Show all open quests"),
func = function(name, param)
minetest.show_formspec(name, "quests:questlog", quests.create_formspec(name))
return true

11
hud.lua
View File

@ -1,3 +1,12 @@
-- Boilerplate to support localized strings if intllib mod is installed.
local S
if minetest.get_modpath("intllib") then
S = intllib.Getter()
else
-- If you don't use insertions (@1, @2, etc) you can use this:
S = function(s) return s end
end
local show_max = 10 -- the maximum visible quests.
local hud_config = { position = {x = 1, y = 0.2},
@ -16,7 +25,7 @@ function quests.show_hud(playername)
position = {x = hud_config.position.x, y = hud_config.position.y},
offset = {x = hud_config.offset.x, y = hud_config.offset.y},
number = hud_config.number,
text = "Quests:" }
text = S("Quests:") }

15
locale/de.txt Normal file
View File

@ -0,0 +1,15 @@
missing description = fehlende Beschreibung
missing title = fehlender Titel
Quests: = Quests:
Abort quest = Quest abbrechen
Configure = Konfigurieren
Enable HUD = HUD einschalten
Exit = Verlassen
Failed quests = Gescheiterte Quests
Finished quests = Beendete Quests
Info = Info
No quest specified. = Keine Quest ausgewählt.
Open quests = Offene Quests
Return = Zurück
Show all open quests = Zeige alle offenen Quests
There are no quests in this category. = Es gibt keine Quests in dieser Kategorie.

15
locale/template.txt Normal file
View File

@ -0,0 +1,15 @@
missing description =
missing title =
Quests: =
Abort quest =
Configure =
Enable HUD =
Exit =
Failed quests =
Finished quests =
Info =
No quest specified. =
Open quests =
Return =
Show all open quests =
There are no quests in this category. =