Improve strings and make them translatable

This commit is contained in:
Wuzzy 2016-08-30 11:31:16 +02:00 committed by rubenwardy
parent 50349917e5
commit 67946bf0c4
6 changed files with 234 additions and 97 deletions

23
api.lua

@ -327,21 +327,23 @@ function awards.getFormspec(name, to, sid)
local item = listofawards[sid+0] local item = listofawards[sid+0]
local def = awards.def[item.name] local def = awards.def[item.name]
if def and def.secret and not item.got then if def and def.secret and not item.got then
formspec = formspec .. "label[1,2.75;(Secret Award)]".. formspec = formspec .. "label[1,2.75;"..minetest.formspec_escape(S("(Secret Award)")).."]"..
"image[1,0;3,3;awards_unknown.png]" "image[1,0;3,3;awards_unknown.png]"
if def and def.description then if def and def.description then
formspec = formspec .. "label[0,3.25;Unlock this award to find out what it is.]" formspec = formspec .. "label[0,3.25;"..minetest.formspec_escape(S("Unlock this award to find out what it is.")).."]"
end end
else else
local title = item.name local title = item.name
if def and def.title then if def and def.title then
title = def.title title = def.title
end end
local status = "" local status = "%s"
if item.got then if item.got then
status = " (got)" status = S("%s (got)")
end end
formspec = formspec .. "label[1,2.75;" .. title .. status .. "]" formspec = formspec .. "label[1,2.75;" ..
string.format(status, minetest.formspec_escape(title)) ..
"]"
if def and def.icon then if def and def.icon then
formspec = formspec .. "image[1,0;3,3;" .. def.icon .. "]" formspec = formspec .. "image[1,0;3,3;" .. def.icon .. "]"
end end
@ -381,7 +383,7 @@ function awards.getFormspec(name, to, sid)
first = false first = false
if def.secret and not award.got then if def.secret and not award.got then
formspec = formspec .. "#707070(Secret Award)" formspec = formspec .. "#707070"..minetest.formspec_escape(S("(Secret Award)"))
else else
local title = award.name local title = award.name
if def and def.title then if def and def.title then
@ -403,23 +405,22 @@ function awards.show_to(name, to, sid, text)
name = to name = to
end end
if name == to and awards.player(to).disabled then if name == to and awards.player(to).disabled then
minetest.chat_send_player("You've disabled awards. Type /awards" .. minetest.chat_send_player(S("You've disabled awards. Type /awards enable to reenable."))
" enable to reenable")
return return
end end
if text then if text then
if not awards.players[name] or not awards.players[name].unlocked then if not awards.players[name] or not awards.players[name].unlocked then
minetest.chat_send_player(to, "You have not unlocked any awards") minetest.chat_send_player(to, S("You have not unlocked any awards"))
return return
end end
minetest.chat_send_player(to, name.."'s awards:") minetest.chat_send_player(to, string.format(S("%ss awards:"), name))
for _, str in pairs(awards.players[name].unlocked) do for _, str in pairs(awards.players[name].unlocked) do
local def = awards.def[str] local def = awards.def[str]
if def then if def then
if def.title then if def.title then
if def.description then if def.description then
minetest.chat_send_player(to, def.title..": "..def.description) minetest.chat_send_player(to, string.format(S("%s: %s"), def.title, def.description))
else else
minetest.chat_send_player(to, def.title) minetest.chat_send_player(to, def.title)
end end

@ -14,20 +14,28 @@
-- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-- --
local S
if (intllib) then
dofile(minetest.get_modpath("intllib").."/intllib.lua")
S = intllib.Getter(minetest.get_current_modname())
else
S = function ( s ) return s end
end
minetest.register_chatcommand("awards", { minetest.register_chatcommand("awards", {
params = "", params = S("[c|clear|disable|enable]"),
description = "awards: list awards", description = S("Show, clear, disable or enable your achievements"),
func = function(name, param) func = function(name, param)
if param == "clear" then if param == "clear" then
awards.clear_player(name) awards.clear_player(name)
minetest.chat_send_player(name, "All your awards and statistics " .. minetest.chat_send_player(name,
" have been cleared. You can now start again.") S("All your awards and statistics have been cleared. You can now start again."))
elseif param == "disable" then elseif param == "disable" then
awards.disable(name) awards.disable(name)
minetest.chat_send_player(name, "You have disabled awards. (only affects you)") minetest.chat_send_player(name, S("You have disabled your achievements."))
elseif param == "enable" then elseif param == "enable" then
awards.enable(name) awards.enable(name)
minetest.chat_send_player(name, "You have enabled awards. (only affects you)") minetest.chat_send_player(name, S("You have enabled your achievements."))
elseif param == "c" then elseif param == "c" then
awards.show_to(name, name, nil, true) awards.show_to(name, name, nil, true)
else else
@ -37,14 +45,14 @@ minetest.register_chatcommand("awards", {
}) })
minetest.register_chatcommand("awd", { minetest.register_chatcommand("awd", {
params = "award name", params = S("<achievement ID>"),
description = "awd: Details of awd gotten", description = S("Show details of an achievement"),
func = function(name, param) func = function(name, param)
local def = awards.def[param] local def = awards.def[param]
if def then if def then
minetest.chat_send_player(name,def.title..": "..def.description) minetest.chat_send_player(name, string.format(S("%s: %s"), def.title, def.description))
else else
minetest.chat_send_player(name,"Award not found.") minetest.chat_send_player(name, S("Achievement not found."))
end end
end end
}) })
@ -53,7 +61,8 @@ minetest.register_chatcommand("awpl", {
privs = { privs = {
server = true server = true
}, },
description = "awpl: Get the statistics for the player given", params = S("<name>"),
description = S("Get the achievements statistics for the given player or yourself"),
func = function(name, param) func = function(name, param)
if not param or param == "" then if not param or param == "" then
param = name param = name

@ -166,7 +166,7 @@ awards.register_achievement("awards_stonebrick2", {
awards.register_achievement("awards_stonebrick3", { awards.register_achievement("awards_stonebrick3", {
title = S("Fortress"), title = S("Fortress"),
description = S("Craft 3200 stone bricks."), description = S("Craft 3,200 stone bricks."),
icon = "default_stone_brick.png^awards_level3.png", icon = "default_stone_brick.png^awards_level3.png",
trigger = { trigger = {
type = "craft", type = "craft",
@ -299,7 +299,7 @@ awards.register_achievement("award_lumberjack_semipro", {
-- Professional Lumberjack -- Professional Lumberjack
awards.register_achievement("award_lumberjack_professional", { awards.register_achievement("award_lumberjack_professional", {
title = S("Professional Lumberjack"), title = S("Professional Lumberjack"),
description = S("Dig 1296 tree blocks."), description = S("Dig 1,296 tree blocks."),
icon = "default_tree.png^awards_level4.png", icon = "default_tree.png^awards_level4.png",
trigger = { trigger = {
type = "dig", type = "dig",
@ -363,7 +363,7 @@ awards.register_achievement("award_meseblock", {
-- You're a copper -- You're a copper
awards.register_achievement("award_youre_a_copper", { awards.register_achievement("award_youre_a_copper", {
title = S("You're a copper"), title = S("Youre a copper"),
description = S("Dig 1,000 copper ores."), description = S("Dig 1,000 copper ores."),
icon = "default_stone.png^default_mineral_copper.png", icon = "default_stone.png^default_mineral_copper.png",
background = "awards_bg_mining.png", background = "awards_bg_mining.png",

@ -1,67 +1,178 @@
Achievement Unlocked: = %d/%d chat messages =
Secret Achievement Unlocked: = %d/%d crafted =
Achievement Unlocked: %s = %d/%d deaths =
Secret Achievement Unlocked: %s = %d/%d dug =
%d/%d game joins =
%d/%d placed =
%s (got) =
%s: %s =
%ss awards: =
(Secret Award) =
/cawards has been deprecated, use /awards c instead. =
<achievement ID> =
<name> =
A Cat in a Pop-Tart?! =
Achievement Unlocked! = Achievement Unlocked! =
Secret Achievement Unlocked! = Achievement Unlocked: =
Light It Up = Achievement Unlocked: %s =
Place 100 torches. = Achievement not found. =
Light ALL The Things! = All your awards and statistics have been cleared. You can now start again. =
Place 1,000 torches. = Aspiring Farmer =
Saint-Maclou =
Place 20 coal checkers. =
Castorama =
Place 20 iron checkers. =
Sam the Trapper =
Place 2 trap stones. =
Obsessed with Obsidian =
Mine 50 obsidian. =
On The Way =
Place 100 rails. =
Lumberjack =
Dig 100 tree blocks. =
Semi-pro Lumberjack =
Dig 1,000 tree blocks. =
Professional Lumberjack =
Dig 10,000 tree blocks. =
L33T Lumberjack =
Dig 100,000 tree blocks. =
Junglebaby =
Dig 100 jungle tree blocks. =
Jungleman =
Dig 1,000 jungle tree blocks. =
First Mese Find =
Find some Mese. =
You're a copper =
Dig 1,000 copper ores. =
OMG, Nyan Cat! =
Find a nyan cat. =
Mini Miner =
Dig 100 stone blocks. =
Hardened Miner =
Dig 1,000 stone blocks =
Master Miner =
Dig 10,000 stone blocks. =
Marchand De Sable =
Dig 1,000 sand. =
Frequent Visitor =
Connect to the server 50 times. =
Dying Spree =
Die 5 times. =
Bot-like =
Die 10 times. =
You Suck! =
Die 100 times. =
You're a witch! =
Burn to death in a fire. =
In the Flow =
Die in flowing lava. =
This is Sad =
Die near diamond ore. =
The Stack =
Die near bones. =
Deep Down =
Die below -10000 =
In space, no one can hear you scream =
Die above 10000 =
Awards = Awards =
Backpacker =
Bankier =
Bricker =
Build a Cave =
Castorama =
Craft 10 furnaces. =
Craft 10 mese lamps. =
Craft 100 obsidian bricks. =
Craft 100 sandstone bricks. =
Craft 100 sticks. =
Craft 100 white dyes. =
Craft 14 vessels shelves. =
Craft 15 chests. =
Craft 15 fancy beds. =
Craft 200 brick blocks. =
Craft 200 stone bricks. =
Craft 24 gold block stairs. =
Craft 250 white wool. =
Craft 3,200 stone bricks. =
Craft 30 locked chests. =
Craft 4 large bags. =
Craft 400 blue dyes. =
Craft 400 desert stone bricks. =
Craft 400 red dyes. =
Craft 400 yellow dyes. =
Craft 7 bookshelves. =
Craft 8 times flint and steel. =
Craft 800 stone bricks. =
Craft a diamond block. =
Craft: %d×%s =
Craft: %s =
Crafter of Sticks =
Dandelions are Yellow =
Desert Discoverer =
Desert Dweller =
Die %d times. =
Die. =
Dig 1,000 copper ores. =
Dig 1,000 jungle tree blocks. =
Dig 1,000 sand. =
Dig 1,000 stone blocks. =
Dig 1,296 tree blocks. =
Dig 10,000 stone blocks. =
Dig 100 jungle tree blocks. =
Dig 100 stone blocks. =
Dig 216 tree blocks. =
Dig 36 tree blocks. =
Dig 6 tree blocks. =
Far Lands =
Farming Skills Aquired =
Field Worker =
Filthy Rich =
Firefighter =
First Day in the Woods =
First Gold Find =
First Mese Find =
Fortress =
Geraniums are Blue =
Get the achievements statistics for the given player or yourself =
Girl's Best Friend =
Glacier Discoverer =
Glasser =
Gold Rush =
Grasslands Discoverer =
Hardened Miner =
Hardest Block on Earth =
Harvest 125 fully grown wheat plants. =
Harvest 25 fully grown wheat plants. =
Harvest 625 fully grown wheat plants. =
Harvest a fully grown wheat plant. =
Hotelier =
House of Obsidian =
In the Dungeon =
Industrial Age =
Join the game %d times. =
Join the game. =
Jungle Discoverer =
Junglebaby =
Jungleman =
Lava Miner =
Lava and Water =
Light It Up =
List awards in chat (deprecated) =
Little Library =
Long Ladder =
Lumberjack =
Marchand De Sable =
Master Miner =
Mese Mastery =
Mine 18 diamond ores. =
Mine 45 gold ores. =
Mine 50 obsidian. =
Mine a block: %s =
Mine a mese block. =
Mine a mossy cobblestone. =
Mine a nyan cat. =
Mine any block while being very close to lava. =
Mine blocks: %d×%s =
Mine some dry grass. =
Mine some grass. =
Mine your first cactus. =
Mine your first diamond ore. =
Mine your first dry shrub. =
Mine your first gold ore. =
Mine your first ice. =
Mine your first jungle grass. =
Mine your first mese ore. =
Mine your first obsidian. =
Mini Miner =
Obsessed with Obsidian =
On The Way =
Outpost =
Pharaoh =
Place 1,000 torches. =
Place 100 rails. =
Place 100 stone. =
Place 100 torches. =
Place 2 trap stones. =
Place 20 coal checkers. =
Place 20 iron checkers. =
Place 40 steel ladders. =
Place 400 wooden ladders. =
Place a block: %s =
Place blocks: %d×%s =
Place two snow blocks. =
Professional Lumberjack =
Put out 1000 fires. =
Pyromaniac =
Really Well Lit =
Roses Are Red =
Saint-Maclou =
Sam the Trapper =
Savannah Discoverer =
Secret Achievement Unlocked! =
Secret Achievement Unlocked: =
Secret Achievement Unlocked: %s =
Semi-pro Lumberjack =
Show details of an achievement =
Show, clear, disable or enable your achievements =
Smelter =
Treasurer =
Unlock this award to find out what it is. =
Very Simple Snow Man =
Watchtower =
Well Lit =
Wheat Magnate =
White Color Stock =
Wool Over Your Eyes =
Wow, I am Diamonds! =
Write %d chat messages. =
Write something in chat. =
You have disabled your achievements. =
You have enabled your achievements. =
You have not unlocked any awards =
You've disabled awards. Type /awards enable to reenable. =
Youre a copper =
[c|clear|disable|enable] =

@ -1,6 +1,14 @@
if minetest.get_modpath("sfinv") then if minetest.get_modpath("sfinv") then
local S
if (intllib) then
dofile(minetest.get_modpath("intllib").."/intllib.lua")
S = intllib.Getter(minetest.get_current_modname())
else
S = function ( s ) return s end
end
sfinv.register_page("awards:awards", { sfinv.register_page("awards:awards", {
title = "Awards", title = S("Awards"),
on_enter = function(self, player, context) on_enter = function(self, player, context)
context.awards_idx = 1 context.awards_idx = 1
end, end,

@ -14,6 +14,14 @@
-- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-- --
local S
if (intllib) then
dofile(minetest.get_modpath("intllib").."/intllib.lua")
S = intllib.Getter(minetest.get_current_modname())
else
S = function ( s ) return s end
end
awards.register_trigger("dig", function(def) awards.register_trigger("dig", function(def)
local tmp = { local tmp = {
award = def.name, award = def.name,
@ -25,7 +33,7 @@ awards.register_trigger("dig", function(def)
local itemcount = awards.get_item_count(data, "count", tmp.node) or 0 local itemcount = awards.get_item_count(data, "count", tmp.node) or 0
return { return {
perc = itemcount / tmp.target, perc = itemcount / tmp.target,
label = itemcount .. " / " .. tmp.target .. " dug" -- TODO: translation label = string.format(S("%d/%d dug"), itemcount, tmp.target)
} }
end end
end) end)
@ -41,7 +49,7 @@ awards.register_trigger("place", function(def)
local itemcount = awards.get_item_count(data, "place", tmp.node) or 0 local itemcount = awards.get_item_count(data, "place", tmp.node) or 0
return { return {
perc = itemcount / tmp.target, perc = itemcount / tmp.target,
label = itemcount .. " / " .. tmp.target .. " placed" -- TODO: translation label = string.format(S("%d/%d placed"), itemcount, tmp.target)
} }
end end
end) end)
@ -56,7 +64,7 @@ awards.register_trigger("death", function(def)
local itemcount = data.deaths or 0 local itemcount = data.deaths or 0
return { return {
perc = itemcount / tmp.target, perc = itemcount / tmp.target,
label = itemcount .. " deaths, need " .. tmp.target -- TODO: translation label = string.format(S("%d/%d deaths"), itemcount, tmp.target)
} }
end end
end) end)
@ -71,7 +79,7 @@ awards.register_trigger("chat", function(def)
local itemcount = data.chats or 0 local itemcount = data.chats or 0
return { return {
perc = itemcount / tmp.target, perc = itemcount / tmp.target,
label = itemcount .. " / " .. tmp.target .. " line of chat" -- TODO: translation label = string.format(S("%d/%d lines of chat"), itemcount, tmp.target)
} }
end end
end) end)
@ -87,7 +95,7 @@ awards.register_trigger("join", function(def)
local itemcount = data.joins or 0 local itemcount = data.joins or 0
return { return {
perc = itemcount / tmp.target, perc = itemcount / tmp.target,
label = itemcount .. " game joins, need " .. tmp.target -- TODO: translation label = string.format(S("%d/%d game joins"), itemcount, tmp.target)
} }
end end
end) end)
@ -103,7 +111,7 @@ awards.register_trigger("craft", function(def)
local itemcount = awards.get_item_count(data, "craft", tmp.item) or 0 local itemcount = awards.get_item_count(data, "craft", tmp.item) or 0
return { return {
perc = itemcount / tmp.target, perc = itemcount / tmp.target,
label = itemcount .. " / " .. tmp.target .. " crafted" -- TODO: translation label = string.format(S("%d/%d crafted"), itemcount, tmp.target)
} }
end end
end) end)