added intllib support and french translation

This commit is contained in:
TenPlus1 2017-05-19 15:05:54 +01:00
parent 18ec8a9bfb
commit 153ef883cc
6 changed files with 70 additions and 5 deletions

View File

@ -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

View File

@ -1,4 +1,5 @@
default
intllib?
farming?
ethereal?
moretrees?

View File

@ -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"))

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

7
locale/fr.txt Normal file
View File

@ -0,0 +1,7 @@
# init.lua
Mulch = Paillis
Bone Meal = Poudre d'os
Fertiliser = Engrais
Bone = Os
[bonemeal] loaded = [bonemeal] chargé

7
locale/template.txt Normal file
View File

@ -0,0 +1,7 @@
# init.lua
Mulch =
Bone Meal =
Fertiliser =
Bone =
[bonemeal] loaded =