Set this up for translation

This commit is contained in:
FaceDeer 2017-02-02 20:56:22 -07:00
parent 69667abc54
commit e2ced0e40c
4 changed files with 159 additions and 14 deletions

View File

@ -1,2 +1,3 @@
default?
doc?
doc?
intllib?

View File

@ -9,9 +9,13 @@
-- When a blank tag stack is used to punch an in-world tag, it inherits that tag's values (continues the chain)
-- Can turn a tag stack blank again via crafting menu
-- internationalization boilerplate
local MP = minetest.get_modpath(minetest.get_current_modname())
local S, NS = dofile(MP.."/intllib.lua")
local glow = minetest.setting_get("breadcrumbs_glow_in_the_dark")
local glow_level
if glow == true or glow == nil then
if (glow == "true") or (glow == nil) then
glow_level = 4
else
glow_level = 0
@ -32,20 +36,24 @@ else
gui_bg_img = ""
end
local blank_longdesc = "A blank path marker sign, ready to have a label affixed"
local blank_usagehelp = "To start marking a new path, wield a stack of blank markers. You'll be presented with a form to fill in a short text label that this path will bear, after which you can begin placing path markers as you explore. You can also use a blank marker stack on an existing path marker that's already been placed and you'll copy the marker's label and continue the path from that point when laying down new markers from your copied stack."
--Doctumentation
local blank_longdesc = S("A blank path marker sign, ready to have a label affixed")
local blank_usagehelp = S("To start marking a new path, wield a stack of blank markers. You'll be presented with a form to fill in a short text label that this path will bear, after which you can begin placing path markers as you explore. You can also use a blank marker stack on an existing path marker that's already been placed and you'll copy the marker's label and continue the path from that point when laying down new markers from your copied stack.")
local marker_longdesc = "A path marker with a label affixed"
local marker_usagehelp = "This marker has had a label assigned and is counting the markers you've been laying down."
local marker_longdesc = S("A path marker with a label affixed")
local marker_usagehelp = S("This marker has had a label assigned and is counting the markers you've been laying down.")
if particles then
marker_usagehelp = marker_usagehelp .. " Each marker knows the location of the previous marker in your path, and right-clicking on it will cause it to emit a stream of indicators that only you can see pointing the direction it lies in."
marker_usagehelp = marker_usagehelp .. " " .. S("Each marker knows the location of the previous marker in your path, and right-clicking on it will cause it to emit a stream of indicators that only you can see pointing the direction it lies in.")
end
marker_usagehelp = marker_usagehelp .. " If you place a marker incorrectly you can \"undo\" the placement by clicking on it with the stack you used to place it. Otherwise, markers can only be removed with an axe. Labeled markers can be turned back into blank markers via the crafting grid."
marker_usagehelp = marker_usagehelp .. " " .. S("If you place a marker incorrectly you can \"undo\" the placement by clicking on it with the stack you used to place it. Otherwise, markers can only be removed with an axe. Labeled markers can be turned back into blank markers via the crafting grid.")
local label_text = S("Label:")
local save_text = S("Save")
local formspec = "size[8,2]" .. gui_bg ..
gui_bg_img ..
"field[0.5,1;7.5,0;label;Label:;]" ..
"button_exit[2.5,1.5;3,1;save;Save]"
"field[0.5,1;7.5,0;label;" .. label_text .. ";]" ..
"button_exit[2.5,1.5;3,1;save;" .. save_text .. "]"
minetest.register_on_player_receive_fields(function(player, formname, fields)
if formname ~= "breadcrumbs:blank" then return end
@ -84,7 +92,7 @@ local read_pointed_thing_tag = function(itemstack, pointed_thing)
end
minetest.register_craftitem("breadcrumbs:blank", {
description = "Blank Marker",
description = S("Blank Marker"),
_doc_items_longdesc = blank_longdesc,
_doc_items_usagehelp = blank_usagehelp,
inventory_image = "breadcrumbs_base.png",
@ -107,8 +115,11 @@ minetest.register_craftitem("breadcrumbs:blank", {
end,
})
local placed_by_text = S("%s #%d\nPlaced by %s")
local distance_from_text = S("%dm from last marker")
minetest.register_node("breadcrumbs:marker", {
description = "Marker",
description = S("Marker"),
_doc_items_longdesc = marker_longdesc,
_doc_items_usagehelp = marker_usagehelp,
drawtype = "nodebox",
@ -160,10 +171,10 @@ minetest.register_node("breadcrumbs:marker", {
node_meta:set_int("previous_pos_z", data.previous_pos.z)
local dist = vector.distance(pos, data.previous_pos)
node_meta:set_string("infotext",
string.format("%s #%d\nPlaced by %s\n%dm from last marker", data.label, data.number, playername, dist))
string.format(placed_by_text .. "\n" .. distance_from_text, data.label, data.number, playername, dist))
else
node_meta:set_string("infotext",
string.format("%s #%d\nPlaced by %s", data.label, data.number, playername))
string.format(placed_by_text, data.label, data.number, playername))
end
data.number = data.number + 1
@ -199,6 +210,8 @@ minetest.register_node("breadcrumbs:marker", {
return itemstack
end,
-- If the player's right-clicking with a blank sign stack, copy the sign's state onto it.
-- Show particle stream directed at last sign, provided particles are enabled for this mod
on_rightclick = function(pos, node, player, itemstack, pointed_thing)
if itemstack:get_name() == "breadcrumbs:blank" then
return tag_to_itemstack(pos, itemstack:get_count())

45
intllib.lua Normal file
View File

@ -0,0 +1,45 @@
-- Fallback functions for when `intllib` is not installed.
-- Code released under Unlicense <http://unlicense.org>.
-- Get the latest version of this file at:
-- https://raw.githubusercontent.com/minetest-mods/intllib/master/lib/intllib.lua
local function format(str, ...)
local args = { ... }
local function repl(escape, open, num, close)
if escape == "" then
local replacement = tostring(args[tonumber(num)])
if open == "" then
replacement = replacement..close
end
return replacement
else
return "@"..open..num..close
end
end
return (str:gsub("(@?)@(%(?)(%d+)(%)?)", repl))
end
local gettext, ngettext
if minetest.get_modpath("intllib") then
if intllib.make_gettext_pair then
-- New method using gettext.
gettext, ngettext = intllib.make_gettext_pair()
else
-- Old method using text files.
gettext = intllib.Getter()
end
end
-- Fill in missing functions.
gettext = gettext or function(msgid, ...)
return format(msgid, ...)
end
ngettext = ngettext or function(msgid, msgid_plural, n, ...)
return format(n==1 and msgid or msgid_plural, ...)
end
return gettext, ngettext

86
locale/template.pot Normal file
View File

@ -0,0 +1,86 @@
# Breadcrumbs mod for Minetest.
# Copyright (C) 2017
# This file is distributed under the same license as the Breadcrumbs package.
# FaceDeer
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-02-02 20:39-0700\n"
"PO-Revision-Date: \n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: init.lua:40
msgid "A blank path marker sign, ready to have a label affixed"
msgstr ""
#: init.lua:41
msgid ""
"To start marking a new path, wield a stack of blank markers. You'll be "
"presented with a form to fill in a short text label that this path will "
"bear, after which you can begin placing path markers as you explore. You can "
"also use a blank marker stack on an existing path marker that's already been "
"placed and you'll copy the marker's label and continue the path from that "
"point when laying down new markers from your copied stack."
msgstr ""
#: init.lua:43
msgid "A path marker with a label affixed"
msgstr ""
#: init.lua:44
msgid ""
"This marker has had a label assigned and is counting the markers you've been "
"laying down."
msgstr ""
#: init.lua:46
msgid ""
"Each marker knows the location of the previous marker in your path, and "
"right-clicking on it will cause it to emit a stream of indicators that only "
"you can see pointing the direction it lies in."
msgstr ""
#: init.lua:48
msgid ""
"If you place a marker incorrectly you can \"undo\" the placement by clicking "
"on it with the stack you used to place it. Otherwise, markers can only be "
"removed with an axe. Labeled markers can be turned back into blank markers "
"via the crafting grid."
msgstr ""
#: init.lua:50
msgid "Label:"
msgstr ""
#: init.lua:51
msgid "Save"
msgstr ""
#: init.lua:95
msgid "Blank Marker"
msgstr ""
# The first %s will be replaced by the label text, the %d by the marker count, and the second %s by the name of the player
#: init.lua:118
#, c-format
msgid ""
"%s #%d\n"
"Placed by %s"
msgstr ""
# The %d will be replaced with the number of meters this marker is from the previous marker in this path
#: init.lua:119
#, c-format
msgid "%dm from last marker"
msgstr ""
#: init.lua:122
msgid "Marker"
msgstr ""