forked from mtcontrib/display_modpack
commit
d59c475162
@ -2,3 +2,4 @@ default
|
||||
dye
|
||||
display_lib
|
||||
|
||||
intllib?
|
||||
|
@ -21,10 +21,11 @@
|
||||
ontime_clocks = {}
|
||||
ontime_clocks.path = minetest.get_modpath("ontime_clocks")
|
||||
|
||||
-- Load support for intllib.
|
||||
local MP = minetest.get_modpath(minetest.get_current_modname())
|
||||
local S, NS = dofile(MP.."/intllib.lua")
|
||||
ontime_clocks.intllib = S
|
||||
|
||||
dofile(ontime_clocks.path.."/common.lua")
|
||||
dofile(ontime_clocks.path.."/nodes.lua")
|
||||
dofile(ontime_clocks.path.."/crafts.lua")
|
||||
|
||||
|
||||
|
||||
|
||||
|
45
ontime_clocks/intllib.lua
Normal file
45
ontime_clocks/intllib.lua
Normal 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
|
43
ontime_clocks/locale/fr.po
Normal file
43
ontime_clocks/locale/fr.po
Normal file
@ -0,0 +1,43 @@
|
||||
# SOME DESCRIPTIVE TITLE.
|
||||
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
||||
# This file is distributed under the same license as the PACKAGE package.
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2017-08-05 09:50+0200\n"
|
||||
"PO-Revision-Date: 2017-05-08 06:20+0200\n"
|
||||
"Last-Translator: Peppy <peppy@twang-factory.com>\n"
|
||||
"Language-Team: \n"
|
||||
"Language: fr\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"X-Generator: Poedit 1.8.12\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
|
||||
|
||||
#: nodes.lua
|
||||
msgid "Green digital clock"
|
||||
msgstr "Horloge numérique verte"
|
||||
|
||||
#: nodes.lua
|
||||
msgid "Red digital clock"
|
||||
msgstr "Horloge numérique rouge"
|
||||
|
||||
#: nodes.lua
|
||||
msgid "White clock"
|
||||
msgstr "Horloge blanche"
|
||||
|
||||
#: nodes.lua
|
||||
msgid "Frameless clock"
|
||||
msgstr "Horloge sans cadre"
|
||||
|
||||
#: nodes.lua
|
||||
msgid "Frameless gold clock"
|
||||
msgstr "Horloge dorée sans cadre"
|
||||
|
||||
#: nodes.lua
|
||||
msgid "Frameless white clock"
|
||||
msgstr "Horloge blanche sans cadre"
|
42
ontime_clocks/locale/template.pot
Normal file
42
ontime_clocks/locale/template.pot
Normal file
@ -0,0 +1,42 @@
|
||||
# SOME DESCRIPTIVE TITLE.
|
||||
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
||||
# This file is distributed under the same license as the PACKAGE package.
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||
#
|
||||
#, fuzzy
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2017-08-05 09:50+0200\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
"Language: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=CHARSET\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
#: nodes.lua
|
||||
msgid "Green digital clock"
|
||||
msgstr ""
|
||||
|
||||
#: nodes.lua
|
||||
msgid "Red digital clock"
|
||||
msgstr ""
|
||||
|
||||
#: nodes.lua
|
||||
msgid "White clock"
|
||||
msgstr ""
|
||||
|
||||
#: nodes.lua
|
||||
msgid "Frameless clock"
|
||||
msgstr ""
|
||||
|
||||
#: nodes.lua
|
||||
msgid "Frameless gold clock"
|
||||
msgstr ""
|
||||
|
||||
#: nodes.lua
|
||||
msgid "Frameless white clock"
|
||||
msgstr ""
|
@ -18,9 +18,11 @@
|
||||
along with ontime_clocks. If not, see <http://www.gnu.org/licenses/>.
|
||||
--]]
|
||||
|
||||
local S = ontime_clocks.intllib
|
||||
|
||||
-- Green digital clock
|
||||
minetest.register_node("ontime_clocks:green_digital", {
|
||||
description = "Green digital clock",
|
||||
description = S("Green digital clock"),
|
||||
inventory_image = "ontime_clocks_green_digital_inventory.png",
|
||||
wield_image = "ontime_clocks_green_digital_inventory.png",
|
||||
paramtype = "light",
|
||||
@ -58,7 +60,7 @@ minetest.register_abm({
|
||||
|
||||
-- Red digital clock
|
||||
minetest.register_node("ontime_clocks:red_digital", {
|
||||
description = "Red digital clock",
|
||||
description = S("Red digital clock"),
|
||||
inventory_image = "ontime_clocks_red_digital_inventory.png",
|
||||
wield_image = "ontime_clocks_red_digital_inventory.png",
|
||||
paramtype = "light",
|
||||
@ -96,7 +98,7 @@ minetest.register_abm({
|
||||
|
||||
|
||||
minetest.register_node("ontime_clocks:white", {
|
||||
description = "White clock",
|
||||
description = S("White clock"),
|
||||
inventory_image = "ontime_clocks_white_inventory.png",
|
||||
wield_image = "ontime_clocks_white_inventory.png",
|
||||
paramtype = "light",
|
||||
@ -133,7 +135,7 @@ minetest.register_abm({
|
||||
})
|
||||
|
||||
minetest.register_node("ontime_clocks:frameless_black", {
|
||||
description = "Frameless clock",
|
||||
description = S("Frameless clock"),
|
||||
inventory_image = "ontime_clocks_frameless_inventory.png",
|
||||
wield_image = "ontime_clocks_frameless_inventory.png",
|
||||
paramtype = "light",
|
||||
@ -170,7 +172,7 @@ minetest.register_abm({
|
||||
})
|
||||
|
||||
minetest.register_node("ontime_clocks:frameless_gold", {
|
||||
description = "Frameless gold clock",
|
||||
description = S("Frameless gold clock"),
|
||||
inventory_image = "ontime_clocks_frameless_inventory.png^[colorize:#FF0",
|
||||
wield_image = "ontime_clocks_frameless_inventory.png^[colorize:#FF0",
|
||||
paramtype = "light",
|
||||
@ -207,7 +209,7 @@ minetest.register_abm({
|
||||
})
|
||||
|
||||
minetest.register_node("ontime_clocks:frameless_white", {
|
||||
description = "Frameless white clock",
|
||||
description = S("Frameless white clock"),
|
||||
inventory_image = "ontime_clocks_frameless_inventory.png^[colorize:#FFF",
|
||||
wield_image = "ontime_clocks_frameless_inventory.png^[colorize:#FFF",
|
||||
paramtype = "light",
|
||||
|
25
ontime_clocks/tools/updatepo.sh
Executable file
25
ontime_clocks/tools/updatepo.sh
Executable file
@ -0,0 +1,25 @@
|
||||
#! /bin/bash
|
||||
|
||||
# To create a new translation:
|
||||
# msginit --locale=ll_CC -o locale/ll_CC.po -i locale/template.pot
|
||||
|
||||
cd "$(dirname "${BASH_SOURCE[0]}")/..";
|
||||
|
||||
# Extract translatable strings.
|
||||
xgettext --from-code=UTF-8 \
|
||||
--language=Lua \
|
||||
--sort-by-file \
|
||||
--keyword=S \
|
||||
--keyword=NS:1,2 \
|
||||
--keyword=N_ \
|
||||
--keyword=F \
|
||||
--add-comments='Translators:' \
|
||||
--add-location=file \
|
||||
-o locale/template.pot \
|
||||
$(find . -name '*.lua')
|
||||
|
||||
# Update translations.
|
||||
find locale -name '*.po' | while read -r file; do
|
||||
echo $file
|
||||
msgmerge --update $file locale/template.pot;
|
||||
done
|
@ -18,6 +18,9 @@
|
||||
along with signs. If not, see <http://www.gnu.org/licenses/>.
|
||||
--]]
|
||||
|
||||
local S = signs.intllib
|
||||
local F = function(...) return minetest.formspec_escape(S(...)) end
|
||||
|
||||
function signs.set_formspec(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local ndef = minetest.registered_nodes[minetest.get_node(pos).name]
|
||||
@ -27,17 +30,17 @@ function signs.set_formspec(pos)
|
||||
|
||||
if maxlines == 1 then
|
||||
formspec = "size[6,3]"..
|
||||
"field[0.5,0.7;5.5,1;display_text;Displayed text;${display_text}]"..
|
||||
"button_exit[2,2;2,1;ok;Write]"
|
||||
"field[0.5,0.7;5.5,1;display_text;"..F("Displayed text")..";${display_text}]"..
|
||||
"button_exit[2,2;2,1;ok;"..F("Write").."]"
|
||||
else
|
||||
local extralabel = ""
|
||||
if maxlines then
|
||||
extralabel = " (first "..maxlines.." lines only)"
|
||||
extralabel = F(" (first %s lines only)"):format(maxlines)
|
||||
end
|
||||
|
||||
formspec = "size[6,4]"..
|
||||
"textarea[0.5,0.7;5.5,2;display_text;Displayed text"..extralabel..";${display_text}]"..
|
||||
"button_exit[2,3;2,1;ok;Write]"
|
||||
"textarea[0.5,0.7;5.5,2;display_text;"..F("Displayed text")..""..extralabel..";${display_text}]"..
|
||||
"button_exit[2,3;2,1;ok;"..F("Write").."]"
|
||||
end
|
||||
|
||||
meta:set_string("formspec", formspec)
|
||||
|
@ -2,3 +2,4 @@ default
|
||||
display_lib
|
||||
font_lib
|
||||
homedecor?
|
||||
intllib?
|
||||
|
@ -21,11 +21,11 @@
|
||||
signs = {}
|
||||
signs.path = minetest.get_modpath("signs")
|
||||
|
||||
-- Load support for intllib.
|
||||
local MP = minetest.get_modpath(minetest.get_current_modname())
|
||||
local S, NS = dofile(MP.."/intllib.lua")
|
||||
signs.intllib = S
|
||||
|
||||
dofile(signs.path.."/common.lua")
|
||||
dofile(signs.path.."/nodes.lua")
|
||||
dofile(signs.path.."/crafts.lua")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
45
signs/intllib.lua
Normal file
45
signs/intllib.lua
Normal 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
|
55
signs/locale/fr.po
Normal file
55
signs/locale/fr.po
Normal file
@ -0,0 +1,55 @@
|
||||
# SOME DESCRIPTIVE TITLE.
|
||||
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
||||
# This file is distributed under the same license as the PACKAGE package.
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2017-08-05 10:06+0200\n"
|
||||
"PO-Revision-Date: 2017-05-08 07:08+0200\n"
|
||||
"Last-Translator: Peppy <peppy@twang-factory.com>\n"
|
||||
"Language-Team: \n"
|
||||
"Language: fr\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"X-Generator: Poedit 1.8.12\n"
|
||||
|
||||
#: common.lua
|
||||
msgid "Displayed text"
|
||||
msgstr "Texte affiché"
|
||||
|
||||
#: common.lua nodes.lua
|
||||
msgid "Write"
|
||||
msgstr "Écrire"
|
||||
|
||||
#: common.lua
|
||||
#, lua-format
|
||||
msgid " (first %s lines only)"
|
||||
msgstr " (uniquement les %s premières lignes)"
|
||||
|
||||
#: nodes.lua
|
||||
msgid "Title"
|
||||
msgstr "Titre"
|
||||
|
||||
#: nodes.lua
|
||||
msgid "Text"
|
||||
msgstr "Texte"
|
||||
|
||||
#: nodes.lua
|
||||
msgid "Close"
|
||||
msgstr "Fermer"
|
||||
|
||||
#: nodes.lua
|
||||
msgid "(right-click to read more text)"
|
||||
msgstr "(Clic-droit pour afficher le texte entier)"
|
||||
|
||||
#: nodes.lua
|
||||
msgid "Wooden direction sign"
|
||||
msgstr "Panneau indicateur en bois"
|
||||
|
||||
#: nodes.lua
|
||||
msgid "Poster"
|
||||
msgstr "Affiche"
|
55
signs/locale/template.pot
Normal file
55
signs/locale/template.pot
Normal file
@ -0,0 +1,55 @@
|
||||
# SOME DESCRIPTIVE TITLE.
|
||||
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
||||
# This file is distributed under the same license as the PACKAGE package.
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||
#
|
||||
#, fuzzy
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2017-08-05 10:06+0200\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
"Language: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=CHARSET\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
#: common.lua
|
||||
msgid "Displayed text"
|
||||
msgstr ""
|
||||
|
||||
#: common.lua nodes.lua
|
||||
msgid "Write"
|
||||
msgstr ""
|
||||
|
||||
#: common.lua
|
||||
#, lua-format
|
||||
msgid " (first %s lines only)"
|
||||
msgstr ""
|
||||
|
||||
#: nodes.lua
|
||||
msgid "Title"
|
||||
msgstr ""
|
||||
|
||||
#: nodes.lua
|
||||
msgid "Text"
|
||||
msgstr ""
|
||||
|
||||
#: nodes.lua
|
||||
msgid "Close"
|
||||
msgstr ""
|
||||
|
||||
#: nodes.lua
|
||||
msgid "(right-click to read more text)"
|
||||
msgstr ""
|
||||
|
||||
#: nodes.lua
|
||||
msgid "Wooden direction sign"
|
||||
msgstr ""
|
||||
|
||||
#: nodes.lua
|
||||
msgid "Poster"
|
||||
msgstr ""
|
@ -18,6 +18,9 @@
|
||||
along with signs. If not, see <http://www.gnu.org/licenses/>.
|
||||
--]]
|
||||
|
||||
local S = signs.intllib
|
||||
local F = function(...) return minetest.formspec_escape(S(...)) end
|
||||
|
||||
-- Poster specific formspec
|
||||
local function on_rightclick_poster(pos, node, player)
|
||||
local formspec
|
||||
@ -25,9 +28,9 @@ local function on_rightclick_poster(pos, node, player)
|
||||
if not minetest.is_protected(pos, player:get_player_name()) then
|
||||
formspec =
|
||||
"size[6.5,7.5]"..
|
||||
"field[0.5,0.7;6,1;display_text;Title;"..minetest.formspec_escape(meta:get_string("display_text")).."]"..
|
||||
"textarea[0.5,1.7;6,6;text;Text;"..minetest.formspec_escape(meta:get_string("text")).."]"..
|
||||
"button_exit[2,7;2,1;ok;Write]"
|
||||
"field[0.5,0.7;6,1;display_text;"..F("Title")..";"..minetest.formspec_escape(meta:get_string("display_text")).."]"..
|
||||
"textarea[0.5,1.7;6,6;text;"..F("Text")..";"..minetest.formspec_escape(meta:get_string("text")).."]"..
|
||||
"button_exit[2,7;2,1;ok;"..F("Write").."]"
|
||||
minetest.show_formspec(player:get_player_name(),
|
||||
"signs:poster@"..minetest.pos_to_string(pos),
|
||||
formspec)
|
||||
@ -37,7 +40,7 @@ local function on_rightclick_poster(pos, node, player)
|
||||
"label[0.5,0;"..minetest.formspec_escape(meta:get_string("display_text")).."]"..
|
||||
"textarea[0.5,1;6,7;;"..minetest.formspec_escape(meta:get_string("text"))..";]"..
|
||||
"bgcolor[#111]"..
|
||||
"button_exit[2,7;2,1;ok;Close]"
|
||||
"button_exit[2,7;2,1;ok;"..F("Close").."]"
|
||||
minetest.show_formspec(player:get_player_name(),
|
||||
"",
|
||||
formspec)
|
||||
@ -53,7 +56,7 @@ local function on_receive_fields_poster(pos, formname, fields, player)
|
||||
meta:set_string("display_text", fields.display_text)
|
||||
meta:set_string("text", fields.text)
|
||||
meta:set_string("infotext", "\""..fields.display_text
|
||||
.."\"\n(right-click to read more text)")
|
||||
.."\"\n"..S("(right-click to read more text)"))
|
||||
display_lib.update_entities(pos)
|
||||
end
|
||||
end
|
||||
@ -75,7 +78,7 @@ local models = {
|
||||
color="#000",
|
||||
},
|
||||
node_fields = {
|
||||
description="Wooden direction sign",
|
||||
description=S("Wooden direction sign"),
|
||||
tiles={"signs_wooden_direction.png"},
|
||||
inventory_image="signs_wooden_inventory.png",
|
||||
on_place=signs.on_place_direction,
|
||||
@ -103,7 +106,7 @@ local models = {
|
||||
color="#000",
|
||||
},
|
||||
node_fields = {
|
||||
description="Wooden direction sign",
|
||||
description=S("Wooden direction sign"),
|
||||
tiles={"signs_wooden_direction.png"},
|
||||
inventory_image="signs_wooden_inventory.png",
|
||||
on_place=signs.on_place_direction,
|
||||
@ -133,7 +136,7 @@ local models = {
|
||||
valign="top",
|
||||
},
|
||||
node_fields = {
|
||||
description="Poster",
|
||||
description=S("Poster"),
|
||||
tiles={"signs_poster.png"},
|
||||
inventory_image="signs_poster_inventory.png",
|
||||
on_construct=display_lib.on_construct,
|
||||
@ -169,4 +172,3 @@ else
|
||||
},
|
||||
})
|
||||
end
|
||||
|
||||
|
25
signs/tools/updatepo.sh
Executable file
25
signs/tools/updatepo.sh
Executable file
@ -0,0 +1,25 @@
|
||||
#! /bin/bash
|
||||
|
||||
# To create a new translation:
|
||||
# msginit --locale=ll_CC -o locale/ll_CC.po -i locale/template.pot
|
||||
|
||||
cd "$(dirname "${BASH_SOURCE[0]}")/..";
|
||||
|
||||
# Extract translatable strings.
|
||||
xgettext --from-code=UTF-8 \
|
||||
--language=Lua \
|
||||
--sort-by-file \
|
||||
--keyword=S \
|
||||
--keyword=NS:1,2 \
|
||||
--keyword=N_ \
|
||||
--keyword=F \
|
||||
--add-comments='Translators:' \
|
||||
--add-location=file \
|
||||
-o locale/template.pot \
|
||||
$(find . -name '*.lua')
|
||||
|
||||
# Update translations.
|
||||
find locale -name '*.po' | while read -r file; do
|
||||
echo $file
|
||||
msgmerge --update $file locale/template.pot;
|
||||
done
|
@ -3,3 +3,4 @@ dye
|
||||
display_lib
|
||||
font_lib
|
||||
signs
|
||||
intllib?
|
||||
|
@ -22,10 +22,10 @@
|
||||
signs_road = {}
|
||||
signs_road.path = minetest.get_modpath("signs_road")
|
||||
|
||||
-- Load support for intllib.
|
||||
local MP = minetest.get_modpath(minetest.get_current_modname())
|
||||
local S, NS = dofile(MP.."/intllib.lua")
|
||||
signs_road.intllib = S
|
||||
|
||||
dofile(signs_road.path.."/nodes.lua")
|
||||
dofile(signs_road.path.."/crafts.lua")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
45
signs_road/intllib.lua
Normal file
45
signs_road/intllib.lua
Normal 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
|
35
signs_road/locale/fr.po
Normal file
35
signs_road/locale/fr.po
Normal file
@ -0,0 +1,35 @@
|
||||
# SOME DESCRIPTIVE TITLE.
|
||||
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
||||
# This file is distributed under the same license as the PACKAGE package.
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2017-08-05 09:50+0200\n"
|
||||
"PO-Revision-Date: 2017-05-08 06:40+0200\n"
|
||||
"Last-Translator: Peppy <peppy@twang-factory.com>\n"
|
||||
"Language-Team: \n"
|
||||
"Language: fr\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"X-Generator: Poedit 1.8.12\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
|
||||
|
||||
#: nodes.lua
|
||||
msgid "Blue street sign"
|
||||
msgstr "Plaque de rue bleue"
|
||||
|
||||
#: nodes.lua
|
||||
msgid "Green street sign"
|
||||
msgstr "Plaque de rue verte"
|
||||
|
||||
#: nodes.lua
|
||||
msgid "Black direction sign"
|
||||
msgstr "Panneau indicateur noir"
|
||||
|
||||
#: nodes.lua
|
||||
msgid "Green direction sign"
|
||||
msgstr "Panneau indicateur vert"
|
34
signs_road/locale/template.pot
Normal file
34
signs_road/locale/template.pot
Normal file
@ -0,0 +1,34 @@
|
||||
# SOME DESCRIPTIVE TITLE.
|
||||
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
||||
# This file is distributed under the same license as the PACKAGE package.
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||
#
|
||||
#, fuzzy
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2017-08-05 09:50+0200\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
"Language: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=CHARSET\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
#: nodes.lua
|
||||
msgid "Blue street sign"
|
||||
msgstr ""
|
||||
|
||||
#: nodes.lua
|
||||
msgid "Green street sign"
|
||||
msgstr ""
|
||||
|
||||
#: nodes.lua
|
||||
msgid "Black direction sign"
|
||||
msgstr ""
|
||||
|
||||
#: nodes.lua
|
||||
msgid "Green direction sign"
|
||||
msgstr ""
|
@ -19,6 +19,8 @@
|
||||
along with signs_road. If not, see <http://www.gnu.org/licenses/>.
|
||||
--]]
|
||||
|
||||
local S = signs_road.intllib
|
||||
|
||||
local models = {
|
||||
blue_street={
|
||||
depth = 1/16,
|
||||
@ -30,7 +32,7 @@ local models = {
|
||||
color="#fff",
|
||||
},
|
||||
node_fields = {
|
||||
description="Blue street sign",
|
||||
description=S("Blue street sign"),
|
||||
tiles={"signs_blue_street.png"},
|
||||
inventory_image="signs_blue_street_inventory.png",
|
||||
},
|
||||
@ -45,7 +47,7 @@ local models = {
|
||||
color="#fff",
|
||||
},
|
||||
node_fields = {
|
||||
description="Green street sign",
|
||||
description=S("Green street sign"),
|
||||
tiles={"signs_green_street.png"},
|
||||
inventory_image="signs_green_street_inventory.png",
|
||||
},
|
||||
@ -60,7 +62,7 @@ local models = {
|
||||
color="#000",
|
||||
},
|
||||
node_fields = {
|
||||
description="Black direction sign",
|
||||
description=S("Black direction sign"),
|
||||
tiles={"signs_black_right.png"},
|
||||
inventory_image="signs_black_inventory.png",
|
||||
on_place=signs.on_place_direction,
|
||||
@ -77,7 +79,7 @@ local models = {
|
||||
color="#000",
|
||||
},
|
||||
node_fields = {
|
||||
description="Black direction sign",
|
||||
description=S("Black direction sign"),
|
||||
tiles={"signs_black_left.png"},
|
||||
inventory_image="signs_black_inventory.png",
|
||||
groups={not_in_creative_inventory=1},
|
||||
@ -97,7 +99,7 @@ local models = {
|
||||
color="#fff",
|
||||
},
|
||||
node_fields = {
|
||||
description="Green direction sign",
|
||||
description=S("Green direction sign"),
|
||||
tiles={"signs_green_direction.png"},
|
||||
inventory_image="signs_green_dir_inventory.png",
|
||||
on_place=signs.on_place_direction,
|
||||
@ -125,7 +127,7 @@ local models = {
|
||||
color="#fff",
|
||||
},
|
||||
node_fields = {
|
||||
description="Green direction sign",
|
||||
description=S("Green direction sign"),
|
||||
tiles={"signs_green_direction.png"},
|
||||
inventory_image="signs_green_dir_inventory.png",
|
||||
on_place=signs.on_place_direction,
|
||||
|
25
signs_road/tools/updatepo.sh
Executable file
25
signs_road/tools/updatepo.sh
Executable file
@ -0,0 +1,25 @@
|
||||
#! /bin/bash
|
||||
|
||||
# To create a new translation:
|
||||
# msginit --locale=ll_CC -o locale/ll_CC.po -i locale/template.pot
|
||||
|
||||
cd "$(dirname "${BASH_SOURCE[0]}")/..";
|
||||
|
||||
# Extract translatable strings.
|
||||
xgettext --from-code=UTF-8 \
|
||||
--language=Lua \
|
||||
--sort-by-file \
|
||||
--keyword=S \
|
||||
--keyword=NS:1,2 \
|
||||
--keyword=N_ \
|
||||
--keyword=F \
|
||||
--add-comments='Translators:' \
|
||||
--add-location=file \
|
||||
-o locale/template.pot \
|
||||
$(find . -name '*.lua')
|
||||
|
||||
# Update translations.
|
||||
find locale -name '*.po' | while read -r file; do
|
||||
echo $file
|
||||
msgmerge --update $file locale/template.pot;
|
||||
done
|
@ -18,6 +18,8 @@
|
||||
along with steles. If not, see <http://www.gnu.org/licenses/>.
|
||||
--]]
|
||||
|
||||
local S = steles.intllib
|
||||
|
||||
steles.materials = {
|
||||
'default:stone',
|
||||
'default:sandstone',
|
||||
@ -26,3 +28,10 @@ steles.materials = {
|
||||
'technic:granite',
|
||||
}
|
||||
|
||||
steles.materials_desc = {
|
||||
S("Stone Stele"),
|
||||
S("Sandstone Stele"),
|
||||
S("Desert Stone Stele"),
|
||||
S("Marble Stele"),
|
||||
S("Granite Stele"),
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
default
|
||||
intllib?
|
||||
display_lib
|
||||
font_lib
|
||||
technic?
|
||||
|
@ -21,10 +21,11 @@
|
||||
steles = {}
|
||||
steles.path = minetest.get_modpath("steles")
|
||||
|
||||
-- Load support for intllib.
|
||||
local MP = minetest.get_modpath(minetest.get_current_modname())
|
||||
local S, NS = dofile(MP.."/intllib.lua")
|
||||
steles.intllib = S
|
||||
|
||||
dofile(steles.path.."/config.lua")
|
||||
dofile(steles.path.."/nodes.lua")
|
||||
dofile(steles.path.."/crafts.lua")
|
||||
|
||||
|
||||
|
||||
|
||||
|
45
steles/intllib.lua
Normal file
45
steles/intllib.lua
Normal 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
|
47
steles/locale/fr.po
Normal file
47
steles/locale/fr.po
Normal file
@ -0,0 +1,47 @@
|
||||
# SOME DESCRIPTIVE TITLE.
|
||||
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
||||
# This file is distributed under the same license as the PACKAGE package.
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2017-08-05 10:06+0200\n"
|
||||
"PO-Revision-Date: 2017-08-05 09:03+0200\n"
|
||||
"Last-Translator: fat115 <fat115@framasoft.org>\n"
|
||||
"Language-Team: \n"
|
||||
"Language: fr\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"X-Generator: Poedit 1.8.12\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
|
||||
|
||||
#: config.lua
|
||||
msgid "Stone Stele"
|
||||
msgstr "Stèle en pierre"
|
||||
|
||||
#: config.lua
|
||||
msgid "Sandstone Stele"
|
||||
msgstr "Stèle en grès"
|
||||
|
||||
#: config.lua
|
||||
msgid "Desert Stone Stele"
|
||||
msgstr "Stèle en pierre du désert"
|
||||
|
||||
#: config.lua
|
||||
msgid "Marble Stele"
|
||||
msgstr "Stèle en marbre"
|
||||
|
||||
#: config.lua
|
||||
msgid "Granite Stele"
|
||||
msgstr "Stèle en granit"
|
||||
|
||||
#: nodes.lua
|
||||
msgid "Displayed text (3 lines max)"
|
||||
msgstr "Texte à afficher (3 lignes maxi.)"
|
||||
|
||||
#: nodes.lua
|
||||
msgid "Write"
|
||||
msgstr "Écrire"
|
46
steles/locale/template.pot
Normal file
46
steles/locale/template.pot
Normal file
@ -0,0 +1,46 @@
|
||||
# SOME DESCRIPTIVE TITLE.
|
||||
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
||||
# This file is distributed under the same license as the PACKAGE package.
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||
#
|
||||
#, fuzzy
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2017-08-05 10:06+0200\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
"Language: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=CHARSET\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
#: config.lua
|
||||
msgid "Stone Stele"
|
||||
msgstr ""
|
||||
|
||||
#: config.lua
|
||||
msgid "Sandstone Stele"
|
||||
msgstr ""
|
||||
|
||||
#: config.lua
|
||||
msgid "Desert Stone Stele"
|
||||
msgstr ""
|
||||
|
||||
#: config.lua
|
||||
msgid "Marble Stele"
|
||||
msgstr ""
|
||||
|
||||
#: config.lua
|
||||
msgid "Granite Stele"
|
||||
msgstr ""
|
||||
|
||||
#: nodes.lua
|
||||
msgid "Displayed text (3 lines max)"
|
||||
msgstr ""
|
||||
|
||||
#: nodes.lua
|
||||
msgid "Write"
|
||||
msgstr ""
|
@ -18,6 +18,9 @@
|
||||
along with steles. If not, see <http://www.gnu.org/licenses/>.
|
||||
--]]
|
||||
|
||||
local S = steles.intllib
|
||||
local F = function(...) return minetest.formspec_escape(S(...)) end
|
||||
|
||||
function steles.on_receive_fields(pos, formname, fields, player)
|
||||
if not minetest.is_protected(pos, player:get_player_name()) then
|
||||
local meta = minetest.get_meta(pos)
|
||||
@ -31,7 +34,7 @@ end
|
||||
|
||||
display_lib.register_display_entity("steles:text")
|
||||
|
||||
for _, material in ipairs(steles.materials) do
|
||||
for i, material in ipairs(steles.materials) do
|
||||
|
||||
local ndef = minetest.registered_nodes[material]
|
||||
|
||||
@ -39,7 +42,7 @@ for _, material in ipairs(steles.materials) do
|
||||
local parts = material:split(":")
|
||||
|
||||
minetest.register_node("steles:"..parts[2].."_stele", {
|
||||
description = ndef.description.." Stele",
|
||||
description = steles.materials_desc[i],
|
||||
sunlight_propagates = true,
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
@ -65,9 +68,11 @@ for _, material in ipairs(steles.materials) do
|
||||
on_place = display_lib.on_place,
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("formspec", "size[6,4]"..
|
||||
"textarea[0.5,0.7;5.5,2;display_text;Displayed text (3 lines max);${display_text}]"..
|
||||
"button_exit[2,3;2,1;ok;Write]")
|
||||
meta:set_string("formspec", "size[6,4]"
|
||||
.."textarea[0.5,0.7;5.5,2;display_text;"
|
||||
..F("Displayed text (3 lines max)")
|
||||
..";${display_text}]"
|
||||
.."button_exit[2,3;2,1;ok;"..F("Write").."]")
|
||||
display_lib.on_construct(pos)
|
||||
end,
|
||||
on_destruct = display_lib.on_destruct,
|
||||
@ -85,4 +90,3 @@ for _, material in ipairs(steles.materials) do
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
|
25
steles/tools/updatepo.sh
Executable file
25
steles/tools/updatepo.sh
Executable file
@ -0,0 +1,25 @@
|
||||
#! /bin/bash
|
||||
|
||||
# To create a new translation:
|
||||
# msginit --locale=ll_CC -o locale/ll_CC.po -i locale/template.pot
|
||||
|
||||
cd "$(dirname "${BASH_SOURCE[0]}")/..";
|
||||
|
||||
# Extract translatable strings.
|
||||
xgettext --from-code=UTF-8 \
|
||||
--language=Lua \
|
||||
--sort-by-file \
|
||||
--keyword=S \
|
||||
--keyword=NS:1,2 \
|
||||
--keyword=N_ \
|
||||
--keyword=F \
|
||||
--add-comments='Translators:' \
|
||||
--add-location=file \
|
||||
-o locale/template.pot \
|
||||
$(find . -name '*.lua')
|
||||
|
||||
# Update translations.
|
||||
find locale -name '*.po' | while read -r file; do
|
||||
echo $file
|
||||
msgmerge --update $file locale/template.pot;
|
||||
done
|
Loading…
Reference in New Issue
Block a user