aboutsummaryrefslogtreecommitdiff
path: root/steles
diff options
context:
space:
mode:
authorfat115 <fat115@framasoft.org>2017-08-05 10:12:43 +0200
committerfat115 <fat115@framasoft.org>2017-08-05 10:12:43 +0200
commit2fef15d878f00c72a799aebc5b8a6bd61489296e (patch)
tree5d5ec63f18bb317fa7c56dcb00c8ffa7f3a62b10 /steles
parent54108e8054ee21e1a3b229f4a4e9e521f5700aa6 (diff)
downloaddisplay_modpack-2fef15d878f00c72a799aebc5b8a6bd61489296e.tar.gz
display_modpack-2fef15d878f00c72a799aebc5b8a6bd61489296e.tar.bz2
display_modpack-2fef15d878f00c72a799aebc5b8a6bd61489296e.zip
add intllib support (i18n)
-> mods ontime_clocks, signs, signs_roads & steles add french translations add updatepo.sh script to update po/pot files add specific array for full description of steles
Diffstat (limited to 'steles')
-rw-r--r--steles/config.lua9
-rw-r--r--steles/depends.txt1
-rw-r--r--steles/init.lua9
-rw-r--r--steles/intllib.lua45
-rw-r--r--steles/locale/fr.po47
-rw-r--r--steles/locale/template.pot46
-rw-r--r--steles/nodes.lua16
-rwxr-xr-xsteles/tools/updatepo.sh25
8 files changed, 188 insertions, 10 deletions
diff --git a/steles/config.lua b/steles/config.lua
index d525010..551429d 100644
--- a/steles/config.lua
+++ b/steles/config.lua
@@ -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"),
+}
diff --git a/steles/depends.txt b/steles/depends.txt
index cf8c669..35625c0 100644
--- a/steles/depends.txt
+++ b/steles/depends.txt
@@ -1,4 +1,5 @@
default
+intllib?
display_lib
font_lib
technic?
diff --git a/steles/init.lua b/steles/init.lua
index dd5068f..a84a596 100644
--- a/steles/init.lua
+++ b/steles/init.lua
@@ -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")
-
-
-
-
diff --git a/steles/intllib.lua b/steles/intllib.lua
new file mode 100644
index 0000000..6669d72
--- /dev/null
+++ b/steles/intllib.lua
@@ -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
diff --git a/steles/locale/fr.po b/steles/locale/fr.po
new file mode 100644
index 0000000..1785d8a
--- /dev/null
+++ b/steles/locale/fr.po
@@ -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"
diff --git a/steles/locale/template.pot b/steles/locale/template.pot
new file mode 100644
index 0000000..f494ee7
--- /dev/null
+++ b/steles/locale/template.pot
@@ -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 ""
diff --git a/steles/nodes.lua b/steles/nodes.lua
index 36515f0..a298293 100644
--- a/steles/nodes.lua
+++ b/steles/nodes.lua
@@ -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
-
diff --git a/steles/tools/updatepo.sh b/steles/tools/updatepo.sh
new file mode 100755
index 0000000..feb2504
--- /dev/null
+++ b/steles/tools/updatepo.sh
@@ -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