summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTenPlus1 <kinsellaja@yahoo.com>2017-05-19 15:05:54 +0100
committerTenPlus1 <kinsellaja@yahoo.com>2017-05-19 15:05:54 +0100
commit153ef883cccadc0e164c9e5632ff7bc12e8e8876 (patch)
treef218ceaa574d13590600de37c67e7df8a7422cc9
parent18ec8a9bfbe40ee416c1c9f4d500a2daf541f33b (diff)
added intllib support and french translation
-rw-r--r--README.md1
-rw-r--r--depends.txt1
-rw-r--r--init.lua14
-rw-r--r--intllib.lua45
-rw-r--r--locale/fr.txt7
-rw-r--r--locale/template.txt7
6 files changed, 70 insertions, 5 deletions
diff --git a/README.md b/README.md
index bf921c1..ed9e0e9 100644
--- a/README.md
+++ b/README.md
@@ -23,3 +23,4 @@ Changelog:
- 0.1 - Initial release
- 0.2 - Added global on_use function for bonemeal growth
- 0.3 - Added strength to on_use global for new items (mulch and fertiliser).
+- 0.4 - Added Intllib support and fr.txt file
diff --git a/depends.txt b/depends.txt
index 6b9ef6f..bbdb1eb 100644
--- a/depends.txt
+++ b/depends.txt
@@ -1,4 +1,5 @@
default
+intllib?
farming?
ethereal?
moretrees?
diff --git a/init.lua b/init.lua
index d3829e8..92c2f03 100644
--- a/init.lua
+++ b/init.lua
@@ -1,6 +1,10 @@
bonemeal = {}
+-- Load support for intllib.
+local MP = minetest.get_modpath(minetest.get_current_modname())
+local S, NS = dofile(MP .. "/intllib.lua")
+
-- default crops
local crops = {
@@ -325,7 +329,7 @@ end
-- mulch (strength 1)
minetest.register_craftitem("bonemeal:mulch", {
- description = "Mulch",
+ description = S("Mulch"),
inventory_image = "bonemeal_mulch.png",
on_use = function(itemstack, user, pointed_thing)
@@ -354,7 +358,7 @@ minetest.register_craftitem("bonemeal:mulch", {
-- bonemeal (strength 2)
minetest.register_craftitem("bonemeal:bonemeal", {
- description = "Bone Meal",
+ description = S("Bone Meal"),
inventory_image = "bonemeal_item.png",
on_use = function(itemstack, user, pointed_thing)
@@ -384,7 +388,7 @@ minetest.register_craftitem("bonemeal:bonemeal", {
-- fertiliser (strength 3)
minetest.register_craftitem("bonemeal:fertiliser", {
- description = "Fertiliser",
+ description = S("Fertiliser"),
inventory_image = "bonemeal_fertiliser.png",
on_use = function(itemstack, user, pointed_thing)
@@ -414,7 +418,7 @@ minetest.register_craftitem("bonemeal:fertiliser", {
-- bone
minetest.register_craftitem("bonemeal:bone", {
- description = "Bone",
+ description = S("Bone"),
inventory_image = "bonemeal_bone.png",
})
@@ -475,4 +479,4 @@ minetest.override_item("default:dirt", {
-- add support for other mods
dofile(minetest.get_modpath("bonemeal") .. "/mods.lua")
-print ("[MOD] Bonemeal loaded")
+print (S("[bonemeal] loaded"))
diff --git a/intllib.lua b/intllib.lua
new file mode 100644
index 0000000..6669d72
--- /dev/null
+++ b/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/locale/fr.txt b/locale/fr.txt
new file mode 100644
index 0000000..874b106
--- /dev/null
+++ b/locale/fr.txt
@@ -0,0 +1,7 @@
+# init.lua
+
+Mulch = Paillis
+Bone Meal = Poudre d'os
+Fertiliser = Engrais
+Bone = Os
+[bonemeal] loaded = [bonemeal] chargé
diff --git a/locale/template.txt b/locale/template.txt
new file mode 100644
index 0000000..f4023ac
--- /dev/null
+++ b/locale/template.txt
@@ -0,0 +1,7 @@
+# init.lua
+
+Mulch =
+Bone Meal =
+Fertiliser =
+Bone =
+[bonemeal] loaded =