Introducing 'game_intllib' and S() for gettext

The new branch 'game_intllib' is aiming at MT internationalization.

Please note the about 400 lines of code changed in the Lua code of the
existing mods by addition of a S("string") enclosure for GNU gettext.
This is in compliance to the GNU gettext toolchain procedures.

'game_intllib' is an attempt at providing internationalization support
for the default game mods specifically. Hopefully, we may delay the
issue of an optimal translation for the MT server into the future.

There is no requirement to include the 'game_intllib' mod into the
game code basis if an alternative solution for a translation of
user-facing strings of the default mods inside the game is in place.
However, the 'game_intllib' and tools may be helpful in assisting the
task of translation of user-facing strings of the default mods prior
a new release of the game and after introduction of new game code.

Please consider to look at my contribution in the MT forum:
https://forum.minetest.net/viewtopic.php?f=11&t=4929&p=346791#p346791

This is up to deliberations of the MT developers and the MT game devs.

*****************

This is the new branch 'game_intllib' comprising the following:

  - changed:   README.txt
  - changed:   mods/beds/beds.lua
  - changed:   mods/beds/depends.txt
  - new file:  mods/beds/gintllib.lua
  - changed:   mods/binoculars/depends.txt
  - new file:  mods/binoculars/gintllib.lua
  - changed:   mods/binoculars/init.lua
  - changed:   mods/boats/depends.txt
  - new file:  mods/boats/gintllib.lua
  - changed:   mods/boats/init.lua
  - changed:   mods/bones/depends.txt
  - new file:  mods/bones/gintllib.lua
  - changed:   mods/bones/init.lua
  - changed:   mods/bucket/depends.txt
  - new file:  mods/bucket/gintllib.lua
  - changed:   mods/bucket/init.lua
  - changed:   mods/butterflies/depends.txt
  - new file:  mods/butterflies/gintllib.lua
  - changed:   mods/butterflies/init.lua
  - changed:   mods/carts/cart_entity.lua
  - changed:   mods/carts/depends.txt
  - new file:  mods/carts/gintllib.lua
  - changed:   mods/carts/rails.lua
  - changed:   mods/creative/depends.txt
  - new file:  mods/creative/gintllib.lua
  - changed:   mods/creative/init.lua
  - changed:   mods/creative/inventory.lua
  - changed:   mods/default/chests.lua
  - changed:   mods/default/craftitems.lua
  - changed:   mods/default/depends.txt
  - changed:   mods/default/furnace.lua
  - new file:  mods/default/gintllib.lua
  - changed:   mods/default/nodes.lua
  - changed:   mods/default/tools.lua
  - changed:   mods/default/torch.lua
  - changed:   mods/default/trees.lua
  - changed:   mods/doors/depends.txt
  - new file:  mods/doors/gintllib.lua
  - changed:   mods/doors/init.lua
  - changed:   mods/dye/depends.txt
  - new file:  mods/dye/gintllib.lua
  - changed:   mods/dye/init.lua
  - changed:   mods/farming/api.lua
  - changed:   mods/farming/depends.txt
  - new file:  mods/farming/gintllib.lua
  - changed:   mods/farming/hoes.lua
  - changed:   mods/farming/init.lua
  - changed:   mods/farming/nodes.lua
  - changed:   mods/fire/depends.txt
  - new file:  mods/fire/gintllib.lua
  - changed:   mods/fire/init.lua
  - changed:   mods/fireflies/depends.txt
  - new file:  mods/fireflies/gintllib.lua
  - changed:   mods/fireflies/init.lua
  - changed:   mods/flowers/depends.txt
  - new file:  mods/flowers/gintllib.lua
  - changed:   mods/flowers/init.lua
  - new file:  mods/game_commands/depends.txt
  - new file:  mods/game_commands/gintllib.lua
  - changed:   mods/game_commands/init.lua
  - new file:  mods/game_intllib/LICENSE.md
  - new file:  mods/game_intllib/README.md
  - new file:  mods/game_intllib/description.txt
  - new file:  mods/game_intllib/doc/developer.md
  - new file:  mods/game_intllib/doc/localefile.md
  - new file:  mods/game_intllib/doc/translator.md
  - new file:  mods/game_intllib/gettext.lua
  - new file:  mods/game_intllib/init.lua
  - new file:  mods/game_intllib/intltest/README.md
  - new file:  mods/game_intllib/intltest/depends.txt
  - new file:  mods/game_intllib/intltest/gintllib.lua
  - new file:  mods/game_intllib/intltest/init.lua
  - new file:  mods/game_intllib/intltest/locale/es.po
  - new file:  mods/game_intllib/intltest/locale/template.pot
  - new file:  mods/game_intllib/lib.lua
  - new file:  mods/game_intllib/lib/gintllib.lua
  - new file:  mods/game_intllib/license.txt
  - new file:  mods/game_intllib/locale/de.po
  - new file:  mods/game_intllib/locale/template.pot
  - new file:  mods/game_intllib/tools/findtext.lua
  - new file:  mods/game_intllib/tools/updatetext.lua
  - new file:  mods/game_intllib/tools/xgettext.bat
  - new file:  mods/game_intllib/tools/xgettext.sh
  - changed:   mods/map/depends.txt
  - new file:  mods/map/gintllib.lua
  - changed:   mods/map/init.lua
  - new file:  mods/screwdriver/depends.txt
  - new file:  mods/screwdriver/gintllib.lua
  - changed:   mods/screwdriver/init.lua
  - new file:  mods/sethome/depends.txt
  - new file:  mods/sethome/gintllib.lua
  - changed:   mods/sethome/init.lua
  - changed:   mods/stairs/depends.txt
  - new file:  mods/stairs/gintllib.lua
  - changed:   mods/stairs/init.lua
  - changed:   mods/tnt/depends.txt
  - new file:  mods/tnt/gintllib.lua
  - changed:   mods/tnt/init.lua
  - changed:   mods/vessels/depends.txt
  - new file:  mods/vessels/gintllib.lua
  - changed:   mods/vessels/init.lua
  - changed:   mods/walls/depends.txt
  - new file:  mods/walls/gintllib.lua
  - changed:   mods/walls/init.lua
  - changed:   mods/wool/depends.txt
  - new file:  mods/wool/gintllib.lua
  - changed:   mods/wool/init.lua
  - changed:   mods/xpanes/depends.txt
  - new file:  mods/xpanes/gintllib.lua
  - changed:   mods/xpanes/init.lua

*****************

The 'game_intllib' internal mod is specifially aimed at default mods
internal to the game in the 'minetest_game' folder.

The original 'intllib' is an attempt at providing internationalization
support for external mods (something Minetest currently lacks).

IMHO the 'intllib' mod is a reliable and helpful tool and I have found
it to be both robust and compliant to the GNU gettext tool chain.

I would like to thank all of the MT developers and certainly @kaeza.
[snoopy (Zweihorn)] 2019-05-13
This commit is contained in:
Zweihorn 2019-05-13 00:53:58 +02:00
parent 5c48c76aa2
commit 2d8d7f4b28
110 changed files with 6661 additions and 481 deletions

View File

@ -15,7 +15,7 @@ The Minetest Game github master HEAD is generally compatible with the github
master HEAD of the Minetest engine.
Additionally, when the Minetest engine is tagged to be a certain version (eg.
0.4.10), Minetest Game is tagged with the version too.
5.0.1), Minetest Game is tagged with the version too.
When stable releases are made, Minetest Game is packaged and made available in
http://minetest.net/downloads/

10
mods/beds/beds.lua Normal file → Executable file
View File

@ -1,7 +1,13 @@
-- beds/beds.lua
-- Load support for game_intllib.
local MP = minetest.get_modpath(minetest.get_current_modname())
local S, NS = dofile(MP .. "/gintllib.lua")
-- Fancy shaped bed
beds.register_bed("beds:fancy_bed", {
description = "Fancy Bed",
description = S("Fancy Bed"),
inventory_image = "beds_bed_fancy.png",
wield_image = "beds_bed_fancy.png",
tiles = {
@ -52,7 +58,7 @@ beds.register_bed("beds:fancy_bed", {
-- Simple shaped bed
beds.register_bed("beds:bed", {
description = "Simple Bed",
description = S("Simple Bed"),
inventory_image = "beds_bed.png",
wield_image = "beds_bed.png",
tiles = {

2
mods/beds/depends.txt Normal file → Executable file
View File

@ -1,2 +1,4 @@
default
wool
game_intllib?

50
mods/beds/gintllib.lua Executable file
View File

@ -0,0 +1,50 @@
-- gintllib.lua
-- should be copied from ../game_intllib/lib/gintllib.lua (2019-05-12)
-- Please note: This is for the default minetest_game mod tree only.
-- For external mods one should make use of the original inttlib mod
-- without interference to the game_intllib mod and it's functions.
-- Fallback functions for when `game_intllib` is not installed.
-- Code released under ../gintllib/LICENSE.md [snoopy (Zweihorn)]
-- Minetest Game Translation with 'game_intllib' (based on 'intllib')
-- Copyright (2019) The Minetest Core & Minetest Game Developers (LGPLv2.1+)
-- Fallback to handle a S("string") enclosure if not installed.
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
-- Hopefully, use make_gettext_pair from game_intllib if installed.
if minetest.get_modpath("game_intllib") then
gettext, ngettext = gintllib.make_gettext_pair()
end
-- Fill in missing functions if game_intllib is not installed.
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

2
mods/binoculars/depends.txt Normal file → Executable file
View File

@ -1,2 +1,4 @@
default
creative?
game_intllib?

50
mods/binoculars/gintllib.lua Executable file
View File

@ -0,0 +1,50 @@
-- gintllib.lua
-- should be copied from ../game_intllib/lib/gintllib.lua (2019-05-12)
-- Please note: This is for the default minetest_game mod tree only.
-- For external mods one should make use of the original inttlib mod
-- without interference to the game_intllib mod and it's functions.
-- Fallback functions for when `game_intllib` is not installed.
-- Code released under ../gintllib/LICENSE.md [snoopy (Zweihorn)]
-- Minetest Game Translation with 'game_intllib' (based on 'intllib')
-- Copyright (2019) The Minetest Core & Minetest Game Developers (LGPLv2.1+)
-- Fallback to handle a S("string") enclosure if not installed.
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
-- Hopefully, use make_gettext_pair from game_intllib if installed.
if minetest.get_modpath("game_intllib") then
gettext, ngettext = gintllib.make_gettext_pair()
end
-- Fill in missing functions if game_intllib is not installed.
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

8
mods/binoculars/init.lua Normal file → Executable file
View File

@ -1,7 +1,13 @@
-- binoculars/init.lua
-- Mod global namespace
binoculars = {}
-- Load support for game_intllib.
local MP = minetest.get_modpath(minetest.get_current_modname())
local S, NS = dofile(MP .. "/gintllib.lua")
-- Detect creative mod
local creative_mod = minetest.get_modpath("creative")
@ -54,7 +60,7 @@ minetest.after(4.7, cyclic_update)
-- Binoculars item
minetest.register_craftitem("binoculars:binoculars", {
description = "Binoculars\nUse with 'Zoom' key",
description = S("Binoculars\nUse with 'Zoom' key"),
inventory_image = "binoculars_binoculars.png",
stack_max = 1,

1
mods/boats/depends.txt Normal file → Executable file
View File

@ -1,2 +1,3 @@
default
player_api
game_intllib?

50
mods/boats/gintllib.lua Executable file
View File

@ -0,0 +1,50 @@
-- gintllib.lua
-- should be copied from ../game_intllib/lib/gintllib.lua (2019-05-12)
-- Please note: This is for the default minetest_game mod tree only.
-- For external mods one should make use of the original inttlib mod
-- without interference to the game_intllib mod and it's functions.
-- Fallback functions for when `game_intllib` is not installed.
-- Code released under ../gintllib/LICENSE.md [snoopy (Zweihorn)]
-- Minetest Game Translation with 'game_intllib' (based on 'intllib')
-- Copyright (2019) The Minetest Core & Minetest Game Developers (LGPLv2.1+)
-- Fallback to handle a S("string") enclosure if not installed.
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
-- Hopefully, use make_gettext_pair from game_intllib if installed.
if minetest.get_modpath("game_intllib") then
gettext, ngettext = gintllib.make_gettext_pair()
end
-- Fill in missing functions if game_intllib is not installed.
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

12
mods/boats/init.lua Normal file → Executable file
View File

@ -1,3 +1,9 @@
-- boats/init.lua
-- Load support for game_intllib.
local MP = minetest.get_modpath(minetest.get_current_modname())
local S, NS = dofile(MP .. "/gintllib.lua")
--
-- Helper functions
--
@ -149,13 +155,13 @@ function boat.on_step(self, dtime)
if ctrl.up and ctrl.down then
if not self.auto then
self.auto = true
minetest.chat_send_player(self.driver, "[boats] Cruise on")
minetest.chat_send_player(self.driver, S("[boats] Cruise on"))
end
elseif ctrl.down then
self.v = self.v - dtime * 1.8
if self.auto then
self.auto = false
minetest.chat_send_player(self.driver, "[boats] Cruise off")
minetest.chat_send_player(self.driver, S("[boats] Cruise off"))
end
elseif ctrl.up or self.auto then
self.v = self.v + dtime * 1.8
@ -242,7 +248,7 @@ minetest.register_entity("boats:boat", boat)
minetest.register_craftitem("boats:boat", {
description = "Boat",
description = S("Boat"),
inventory_image = "boats_inventory.png",
wield_image = "boats_wield.png",
wield_scale = {x = 2, y = 2, z = 1},

2
mods/bones/depends.txt Normal file → Executable file
View File

@ -1 +1,3 @@
default
game_intllib?

50
mods/bones/gintllib.lua Executable file
View File

@ -0,0 +1,50 @@
-- gintllib.lua
-- should be copied from ../game_intllib/lib/gintllib.lua (2019-05-12)
-- Please note: This is for the default minetest_game mod tree only.
-- For external mods one should make use of the original inttlib mod
-- without interference to the game_intllib mod and it's functions.
-- Fallback functions for when `game_intllib` is not installed.
-- Code released under ../gintllib/LICENSE.md [snoopy (Zweihorn)]
-- Minetest Game Translation with 'game_intllib' (based on 'intllib')
-- Copyright (2019) The Minetest Core & Minetest Game Developers (LGPLv2.1+)
-- Fallback to handle a S("string") enclosure if not installed.
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
-- Hopefully, use make_gettext_pair from game_intllib if installed.
if minetest.get_modpath("game_intllib") then
gettext, ngettext = gintllib.make_gettext_pair()
end
-- Fill in missing functions if game_intllib is not installed.
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

27
mods/bones/init.lua Normal file → Executable file
View File

@ -1,6 +1,11 @@
-- Minetest 0.4 mod: bones
-- See README.txt for licensing and other information.
-- Load support for game_intllib.
local MP = minetest.get_modpath(minetest.get_current_modname())
local S, NS = dofile(MP .. "/gintllib.lua")
bones = {}
local function is_owner(pos, name)
@ -24,7 +29,7 @@ local share_bones_time = tonumber(minetest.settings:get("share_bones_time")) or
local share_bones_time_early = tonumber(minetest.settings:get("share_bones_time_early")) or share_bones_time / 4
minetest.register_node("bones:bones", {
description = "Bones",
description = S("Bones"),
tiles = {
"bones_top.png^[transform2",
"bones_bottom.png",
@ -116,7 +121,7 @@ minetest.register_node("bones:bones", {
local meta = minetest.get_meta(pos)
local time = meta:get_int("time") + elapsed
if time >= share_bones_time then
meta:set_string("infotext", meta:get_string("owner") .. "'s old bones")
meta:set_string("infotext", S("@1's old bones", meta:get_string("owner")))
meta:set_string("owner", "")
else
meta:set_int("time", time)
@ -194,7 +199,7 @@ minetest.register_on_dieplayer(function(player)
minetest.log("action", player_name .. " dies at " .. pos_string ..
". No bones placed")
if bones_position_message then
minetest.chat_send_player(player_name, player_name .. " died at " .. pos_string .. ".")
minetest.chat_send_player(player_name, S("@1 died at @2.", player_name, pos_string))
end
return
end
@ -204,7 +209,7 @@ minetest.register_on_dieplayer(function(player)
minetest.log("action", player_name .. " dies at " .. pos_string ..
". No bones placed")
if bones_position_message then
minetest.chat_send_player(player_name, player_name .. " died at " .. pos_string .. ".")
minetest.chat_send_player(player_name, S("@1 died at @2.", player_name, pos_string))
end
return
end
@ -230,8 +235,9 @@ minetest.register_on_dieplayer(function(player)
minetest.log("action", player_name .. " dies at " .. pos_string ..
". Inventory dropped")
if bones_position_message then
minetest.chat_send_player(player_name, player_name .. " died at " .. pos_string ..
", and dropped their inventory.")
minetest.chat_send_player(player_name,
S("@1 died at @2, and dropped their inventory.",
player_name, pos_string))
end
return
end
@ -242,8 +248,9 @@ minetest.register_on_dieplayer(function(player)
minetest.log("action", player_name .. " dies at " .. pos_string ..
". Bones placed")
if bones_position_message then
minetest.chat_send_player(player_name, player_name .. " died at " .. pos_string ..
", and bones were placed.")
minetest.chat_send_player(player_name,
S("@1 died at @2, and bones were placed.",
player_name, pos_string))
end
local meta = minetest.get_meta(pos)
@ -266,7 +273,7 @@ minetest.register_on_dieplayer(function(player)
meta:set_string("owner", player_name)
if share_bones_time ~= 0 then
meta:set_string("infotext", player_name .. "'s fresh bones")
meta:set_string("infotext", S("@1's fresh bones.", player_name))
if share_bones_time_early == 0 or not minetest.is_protected(pos, player_name) then
meta:set_int("time", 0)
@ -276,6 +283,6 @@ minetest.register_on_dieplayer(function(player)
minetest.get_node_timer(pos):start(10)
else
meta:set_string("infotext", player_name.."'s bones")
meta:set_string("infotext", S("@1's bones.", player_name))
end
end)

2
mods/bucket/depends.txt Normal file → Executable file
View File

@ -1,2 +1,4 @@
default
game_intllib?

50
mods/bucket/gintllib.lua Executable file
View File

@ -0,0 +1,50 @@
-- gintllib.lua
-- should be copied from ../game_intllib/lib/gintllib.lua (2019-05-12)
-- Please note: This is for the default minetest_game mod tree only.
-- For external mods one should make use of the original inttlib mod
-- without interference to the game_intllib mod and it's functions.
-- Fallback functions for when `game_intllib` is not installed.
-- Code released under ../gintllib/LICENSE.md [snoopy (Zweihorn)]
-- Minetest Game Translation with 'game_intllib' (based on 'intllib')
-- Copyright (2019) The Minetest Core & Minetest Game Developers (LGPLv2.1+)
-- Fallback to handle a S("string") enclosure if not installed.
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
-- Hopefully, use make_gettext_pair from game_intllib if installed.
if minetest.get_modpath("game_intllib") then
gettext, ngettext = gintllib.make_gettext_pair()
end
-- Fill in missing functions if game_intllib is not installed.
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

13
mods/bucket/init.lua Normal file → Executable file
View File

@ -1,6 +1,11 @@
-- Minetest 0.4 mod: bucket
-- See README.txt for licensing and other information.
-- Load support for game_intllib.
local MP = minetest.get_modpath(minetest.get_current_modname())
local S, NS = dofile(MP .. "/gintllib.lua")
minetest.register_alias("bucket", "bucket:bucket_empty")
minetest.register_alias("bucket_water", "bucket:bucket_water")
minetest.register_alias("bucket_lava", "bucket:bucket_lava")
@ -111,7 +116,7 @@ function bucket.register_liquid(source, flowing, itemname, inventory_image, name
end
minetest.register_craftitem("bucket:bucket_empty", {
description = "Empty Bucket",
description = S("Empty Bucket"),
inventory_image = "bucket.png",
stack_max = 99,
liquids_pointable = true,
@ -185,7 +190,7 @@ bucket.register_liquid(
"default:water_flowing",
"bucket:bucket_water",
"bucket_water.png",
"Water Bucket",
S("Water Bucket"),
{water_bucket = 1}
)
@ -200,7 +205,7 @@ bucket.register_liquid(
"default:river_water_flowing",
"bucket:bucket_river_water",
"bucket_river_water.png",
"River Water Bucket",
S("River Water Bucket"),
{water_bucket = 1},
true
)
@ -210,7 +215,7 @@ bucket.register_liquid(
"default:lava_flowing",
"bucket:bucket_lava",
"bucket_lava.png",
"Lava Bucket"
S("Lava Bucket")
)
minetest.register_craft({

3
mods/butterflies/depends.txt Normal file → Executable file
View File

@ -1,2 +1,3 @@
default
flowers
flowers
game_intllib?

50
mods/butterflies/gintllib.lua Executable file
View File

@ -0,0 +1,50 @@
-- gintllib.lua
-- should be copied from ../game_intllib/lib/gintllib.lua (2019-05-12)
-- Please note: This is for the default minetest_game mod tree only.
-- For external mods one should make use of the original inttlib mod
-- without interference to the game_intllib mod and it's functions.
-- Fallback functions for when `game_intllib` is not installed.
-- Code released under ../gintllib/LICENSE.md [snoopy (Zweihorn)]
-- Minetest Game Translation with 'game_intllib' (based on 'intllib')
-- Copyright (2019) The Minetest Core & Minetest Game Developers (LGPLv2.1+)
-- Fallback to handle a S("string") enclosure if not installed.
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
-- Hopefully, use make_gettext_pair from game_intllib if installed.
if minetest.get_modpath("game_intllib") then
gettext, ngettext = gintllib.make_gettext_pair()
end
-- Fill in missing functions if game_intllib is not installed.
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

16
mods/butterflies/init.lua Normal file → Executable file
View File

@ -1,8 +1,14 @@
-- butrerflies/init.lua
-- Load support for game_intllib.
local MP = minetest.get_modpath(minetest.get_current_modname())
local S, NS = dofile(MP .. "/gintllib.lua")
-- register butterflies
local butter_list = {
{"white", "White"},
{"red", "Red"},
{"violet", "Violet"}
{"white", S("White")},
{"red", S("Red")},
{"violet", S("Violet")}
}
for i in ipairs (butter_list) do
@ -10,7 +16,7 @@ for i in ipairs (butter_list) do
local desc = butter_list[i][2]
minetest.register_node("butterflies:butterfly_"..name, {
description = desc.." Butterfly",
description = S("@1 Butterfly", desc),
drawtype = "plantlike",
tiles = {{
name = "butterflies_butterfly_"..name.."_animated.png",
@ -56,7 +62,7 @@ for i in ipairs (butter_list) do
})
minetest.register_node("butterflies:hidden_butterfly_"..name, {
description = "Hidden "..desc.." Butterfly",
description = S("Hidden @1 Butterfly", desc),
drawtype = "airlike",
inventory_image = "insects_butterfly_"..name..".png",
wield_image = "insects_butterfly_"..name..".png",

9
mods/carts/cart_entity.lua Normal file → Executable file
View File

@ -1,3 +1,10 @@
-- carts/cart_entity.lua
-- Load support for game_intllib.
local MP = minetest.get_modpath(minetest.get_current_modname())
local S, NS = dofile(MP .. "/gintllib.lua")
local cart_entity = {
initial_properties = {
physical = false, -- otherwise going uphill breaks
@ -383,7 +390,7 @@ end
minetest.register_entity("carts:cart", cart_entity)
minetest.register_craftitem("carts:cart", {
description = "Cart (Sneak+Click to pick up)",
description = S("Cart (Sneak+Click to pick up)"),
inventory_image = minetest.inventorycube("carts_cart_top.png", "carts_cart_side.png", "carts_cart_side.png"),
wield_image = "carts_cart_side.png",
on_place = function(itemstack, placer, pointed_thing)

1
mods/carts/depends.txt Normal file → Executable file
View File

@ -1,2 +1,3 @@
default
player_api
game_intllib?

50
mods/carts/gintllib.lua Executable file
View File

@ -0,0 +1,50 @@
-- gintllib.lua
-- should be copied from ../game_intllib/lib/gintllib.lua (2019-05-12)
-- Please note: This is for the default minetest_game mod tree only.
-- For external mods one should make use of the original inttlib mod
-- without interference to the game_intllib mod and it's functions.
-- Fallback functions for when `game_intllib` is not installed.
-- Code released under ../gintllib/LICENSE.md [snoopy (Zweihorn)]
-- Minetest Game Translation with 'game_intllib' (based on 'intllib')
-- Copyright (2019) The Minetest Core & Minetest Game Developers (LGPLv2.1+)
-- Fallback to handle a S("string") enclosure if not installed.
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
-- Hopefully, use make_gettext_pair from game_intllib if installed.
if minetest.get_modpath("game_intllib") then
gettext, ngettext = gintllib.make_gettext_pair()
end
-- Fill in missing functions if game_intllib is not installed.
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

12
mods/carts/rails.lua Normal file → Executable file
View File

@ -1,5 +1,11 @@
-- carts/rails.lua
-- Load support for game_intllib.
local MP = minetest.get_modpath(minetest.get_current_modname())
local S, NS = dofile(MP .. "/gintllib.lua")
carts:register_rail("carts:rail", {
description = "Rail",
description = S("Rail"),
tiles = {
"carts_rail_straight.png", "carts_rail_curved.png",
"carts_rail_t_junction.png", "carts_rail_crossing.png"
@ -22,7 +28,7 @@ minetest.register_alias("default:rail", "carts:rail")
carts:register_rail("carts:powerrail", {
description = "Powered Rail",
description = S("Powered Rail"),
tiles = {
"carts_rail_straight_pwr.png", "carts_rail_curved_pwr.png",
"carts_rail_t_junction_pwr.png", "carts_rail_crossing_pwr.png"
@ -41,7 +47,7 @@ minetest.register_craft({
carts:register_rail("carts:brakerail", {
description = "Brake Rail",
description = S("Brake Rail"),
tiles = {
"carts_rail_straight_brk.png", "carts_rail_curved_brk.png",
"carts_rail_t_junction_brk.png", "carts_rail_crossing_brk.png"

1
mods/creative/depends.txt Normal file → Executable file
View File

@ -1,2 +1,3 @@
default
sfinv
game_intllib?

50
mods/creative/gintllib.lua Executable file
View File

@ -0,0 +1,50 @@
-- gintllib.lua
-- should be copied from ../game_intllib/lib/gintllib.lua (2019-05-12)
-- Please note: This is for the default minetest_game mod tree only.
-- For external mods one should make use of the original inttlib mod
-- without interference to the game_intllib mod and it's functions.
-- Fallback functions for when `game_intllib` is not installed.
-- Code released under ../gintllib/LICENSE.md [snoopy (Zweihorn)]
-- Minetest Game Translation with 'game_intllib' (based on 'intllib')
-- Copyright (2019) The Minetest Core & Minetest Game Developers (LGPLv2.1+)
-- Fallback to handle a S("string") enclosure if not installed.
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
-- Hopefully, use make_gettext_pair from game_intllib if installed.
if minetest.get_modpath("game_intllib") then
gettext, ngettext = gintllib.make_gettext_pair()
end
-- Fill in missing functions if game_intllib is not installed.
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

9
mods/creative/init.lua Normal file → Executable file
View File

@ -1,3 +1,10 @@
-- creative/init.lua
-- Load support for game_intllib.
local MP = minetest.get_modpath(minetest.get_current_modname())
local S, NS = dofile(MP .. "/gintllib.lua")
creative = {}
local function update_sfinv(name)
@ -14,7 +21,7 @@ local function update_sfinv(name)
end
minetest.register_privilege("creative", {
description = "Allow player to use creative inventory",
description = S("Allow player to use creative inventory"),
give_to_singleplayer = false,
give_to_admin = false,
on_grant = update_sfinv,

15
mods/creative/inventory.lua Normal file → Executable file
View File

@ -1,3 +1,10 @@
-- creative/inventory.lua
-- Load support for game_intllib.
local MP = minetest.get_modpath(minetest.get_current_modname())
local S, NS = dofile(MP .. "/gintllib.lua")
local player_inventory = {}
local inventory_cache = {}
@ -176,10 +183,10 @@ function creative.register_tab(name, title, items)
})
end
creative.register_tab("all", "All", minetest.registered_items)
creative.register_tab("nodes", "Nodes", minetest.registered_nodes)
creative.register_tab("tools", "Tools", minetest.registered_tools)
creative.register_tab("craftitems", "Items", minetest.registered_craftitems)
creative.register_tab("all", S("All"), minetest.registered_items)
creative.register_tab("nodes", S("Nodes"), minetest.registered_nodes)
creative.register_tab("tools", S("Tools"), minetest.registered_tools)
creative.register_tab("craftitems", S("Items"), minetest.registered_craftitems)
local old_homepage_name = sfinv.get_homepage_name
function sfinv.get_homepage_name(player)

20
mods/default/chests.lua Normal file → Executable file
View File

@ -1,5 +1,9 @@
default.chest = {}
-- Load support for game_intllib.
local MP = minetest.get_modpath(minetest.get_current_modname())
local S, NS = dofile(MP .. "/gintllib.lua")
function default.chest.get_chest_formspec(pos)
local spos = pos.x .. "," .. pos.y .. "," .. pos.z
local formspec =
@ -84,7 +88,7 @@ function default.chest.register_chest(name, d)
if def.protected then
def.on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string("infotext", "Locked Chest")
meta:set_string("infotext", S("Locked Chest"))
meta:set_string("owner", "")
local inv = meta:get_inventory()
inv:set_size("main", 8*4)
@ -92,8 +96,8 @@ function default.chest.register_chest(name, d)
def.after_place_node = function(pos, placer)
local meta = minetest.get_meta(pos)
meta:set_string("owner", placer:get_player_name() or "")
meta:set_string("infotext", "Locked Chest (owned by " ..
meta:get_string("owner") .. ")")
meta:set_string("infotext", S("Locked Chest (owned by @1)",
meta:get_string("owner")))
end
def.can_dig = function(pos,player)
local meta = minetest.get_meta(pos);
@ -171,7 +175,7 @@ function default.chest.register_chest(name, d)
-- verify placer is owner of lockable chest
if owner ~= pn then
minetest.record_protection_violation(pos, pn)
minetest.chat_send_player(pn, "You do not own this chest.")
minetest.chat_send_player(pn, S("You do not own this chest."))
return nil
end
@ -181,12 +185,12 @@ function default.chest.register_chest(name, d)
meta:set_string("key_lock_secret", secret)
end
return secret, "a locked chest", owner
return secret, S("a locked chest"), owner
end
else
def.on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string("infotext", "Chest")
meta:set_string("infotext", S("Chest"))
local inv = meta:get_inventory()
inv:set_size("main", 8*4)
end
@ -285,7 +289,7 @@ function default.chest.register_chest(name, d)
end
default.chest.register_chest("chest", {
description = "Chest",
description = S("Chest"),
tiles = {
"default_chest_top.png",
"default_chest_top.png",
@ -301,7 +305,7 @@ default.chest.register_chest("chest", {
})
default.chest.register_chest("chest_locked", {
description = "Locked Chest",
description = S("Locked Chest"),
tiles = {
"default_chest_top.png",
"default_chest_top.png",

55
mods/default/craftitems.lua Normal file → Executable file
View File

@ -1,13 +1,17 @@
-- mods/default/craftitems.lua
-- Load support for game_intllib.
local MP = minetest.get_modpath(minetest.get_current_modname())
local S, NS = dofile(MP .. "/gintllib.lua")
minetest.register_craftitem("default:stick", {
description = "Stick",
description = S("Stick"),
inventory_image = "default_stick.png",
groups = {stick = 1, flammable = 2},
})
minetest.register_craftitem("default:paper", {
description = "Paper",
description = S("Paper"),
inventory_image = "default_paper.png",
groups = {flammable = 3},
})
@ -108,7 +112,9 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
if #short_title > short_title_size + 3 then
short_title = short_title:sub(1, short_title_size) .. "..."
end
data.description = "\""..short_title.."\" by "..data.owner
-- Make description appropriate to intllib
-- data.description = "\""..short_title.."\" by "..data.owner
data.description = S("\"@1\" by @2", short_title, data.owner)
data.text = fields.text:sub(1, max_text_size)
data.text = data.text:gsub("\r\n", "\n"):gsub("\r", "\n")
data.page = 1
@ -155,14 +161,14 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
end)
minetest.register_craftitem("default:book", {
description = "Book",
description = S("Book"),
inventory_image = "default_book.png",
groups = {book = 1, flammable = 3},
on_use = book_on_use,
})
minetest.register_craftitem("default:book_written", {
description = "Book With Text",
description = S("Book With Text"),
inventory_image = "default_book_written.png",
groups = {book = 1, not_in_creative_inventory = 1, flammable = 3},
stack_max = 1,
@ -199,7 +205,7 @@ minetest.register_on_craft(function(itemstack, player, old_craft_grid, craft_inv
end)
minetest.register_craftitem("default:skeleton_key", {
description = "Skeleton Key",
description = S("Skeleton Key"),
inventory_image = "default_key_skeleton.png",
groups = {key = 1},
on_use = function(itemstack, user, pointed_thing)
@ -255,94 +261,93 @@ minetest.register_craftitem("default:skeleton_key", {
})
minetest.register_craftitem("default:coal_lump", {
description = "Coal Lump",
description = S("Coal Lump"),
inventory_image = "default_coal_lump.png",
groups = {coal = 1, flammable = 1}
})
minetest.register_craftitem("default:iron_lump", {
description = "Iron Lump",
description = S("Iron Lump"),
inventory_image = "default_iron_lump.png",
})
minetest.register_craftitem("default:copper_lump", {
description = "Copper Lump",
description = S("Copper Lump"),
inventory_image = "default_copper_lump.png",
})
minetest.register_craftitem("default:tin_lump", {
description = "Tin Lump",
description = S("Tin Lump"),
inventory_image = "default_tin_lump.png",
})
minetest.register_craftitem("default:mese_crystal", {
description = "Mese Crystal",
description = S("Mese Crystal"),
inventory_image = "default_mese_crystal.png",
})
minetest.register_craftitem("default:gold_lump", {
description = "Gold Lump",
description = S("Gold Lump"),
inventory_image = "default_gold_lump.png",
})
minetest.register_craftitem("default:diamond", {
description = "Diamond",
description = S("Diamond"),
inventory_image = "default_diamond.png",
})
minetest.register_craftitem("default:clay_lump", {
description = "Clay Lump",
description = S("Clay Lump"),
inventory_image = "default_clay_lump.png",
})
minetest.register_craftitem("default:steel_ingot", {
description = "Steel Ingot",
description = S("Steel Ingot"),
inventory_image = "default_steel_ingot.png",
})
minetest.register_craftitem("default:copper_ingot", {
description = "Copper Ingot",
description = S("Copper Ingot"),
inventory_image = "default_copper_ingot.png",
})
minetest.register_craftitem("default:tin_ingot", {
description = "Tin Ingot",
description = S("Tin Ingot"),
inventory_image = "default_tin_ingot.png",
})
minetest.register_craftitem("default:bronze_ingot", {
description = "Bronze Ingot",
description = S("Bronze Ingot"),
inventory_image = "default_bronze_ingot.png",
})
minetest.register_craftitem("default:gold_ingot", {
description = "Gold Ingot",
description = S("Gold Ingot"),
inventory_image = "default_gold_ingot.png"
})
minetest.register_craftitem("default:mese_crystal_fragment", {
description = "Mese Crystal Fragment",
description = S("Mese Crystal Fragment"),
inventory_image = "default_mese_crystal_fragment.png",
})
minetest.register_craftitem("default:clay_brick", {
description = "Clay Brick",
description = S("Clay Brick"),
inventory_image = "default_clay_brick.png",
})
minetest.register_craftitem("default:obsidian_shard", {
description = "Obsidian Shard",
description = S("Obsidian Shard"),
inventory_image = "default_obsidian_shard.png",
})
minetest.register_craftitem("default:flint", {
description = "Flint",
description = S("Flint"),
inventory_image = "default_flint.png"
})
minetest.register_craftitem("default:blueberries", {
description = "Blueberries",
description = S("Blueberries"),
inventory_image = "default_blueberries.png",
groups = {food_blueberries = 1, food_berry = 1},
on_use = minetest.item_eat(2),
})

1
mods/default/depends.txt Normal file → Executable file
View File

@ -1 +1,2 @@
player_api?
game_intllib?

28
mods/default/furnace.lua Normal file → Executable file
View File

@ -1,3 +1,9 @@
-- default/furnace.lua
-- Load support for game_intllib.
local MP = minetest.get_modpath(minetest.get_current_modname())
local S, NS = dofile(MP .. "/gintllib.lua")
--
-- Formspecs
@ -60,7 +66,7 @@ local function allow_metadata_inventory_put(pos, listname, index, stack, player)
if listname == "fuel" then
if minetest.get_craft_result({method="fuel", width=1, items={stack}}).time ~= 0 then
if inv:is_empty("src") then
meta:set_string("infotext", "Furnace is empty")
meta:set_string("infotext", S("Furnace is empty"))
end
return stack:get_count()
else
@ -196,19 +202,19 @@ local function furnace_node_timer(pos, elapsed)
if cookable then
item_percent = math.floor(src_time / cooked.time * 100)
if item_percent > 100 then
item_state = "100% (output full)"
item_state = S("100% (output full)")
else
item_state = item_percent .. "%"
item_state = S("@1%", item_percent)
end
else
if srclist[1]:is_empty() then
item_state = "Empty"
item_state = S("Empty")
else
item_state = "Not cookable"
item_state = S("Not cookable")
end
end
local fuel_state = "Empty"
local fuel_state = S("Empty")
local active = "inactive"
local result = false
@ -230,8 +236,10 @@ local function furnace_node_timer(pos, elapsed)
minetest.get_node_timer(pos):stop()
end
local infotext = "Furnace " .. active .. "\n(Item: " .. item_state ..
"; Fuel: " .. fuel_state .. ")"
-- local infotext = "Furnace " .. active .. "\n(Item: " .. item_state ..
-- "; Fuel: " .. fuel_state .. ")"
local infotext = S("Furnace @1 \n(Item: @2; Fuel: @3)", active,
item_state, fuel_state)
--
-- Set meta values
@ -250,7 +258,7 @@ end
--
minetest.register_node("default:furnace", {
description = "Furnace",
description = S("Furnace"),
tiles = {
"default_furnace_top.png", "default_furnace_bottom.png",
"default_furnace_side.png", "default_furnace_side.png",
@ -298,7 +306,7 @@ minetest.register_node("default:furnace", {
})
minetest.register_node("default:furnace_active", {
description = "Furnace",
description = S("Furnace"),
tiles = {
"default_furnace_top.png", "default_furnace_bottom.png",
"default_furnace_side.png", "default_furnace_side.png",

50
mods/default/gintllib.lua Executable file
View File

@ -0,0 +1,50 @@
-- gintllib.lua
-- should be copied from ../game_intllib/lib/gintllib.lua (2019-05-12)
-- Please note: This is for the default minetest_game mod tree only.
-- For external mods one should make use of the original inttlib mod
-- without interference to the game_intllib mod and it's functions.
-- Fallback functions for when `game_intllib` is not installed.
-- Code released under ../gintllib/LICENSE.md [snoopy (Zweihorn)]
-- Minetest Game Translation with 'game_intllib' (based on 'intllib')
-- Copyright (2019) The Minetest Core & Minetest Game Developers (LGPLv2.1+)
-- Fallback to handle a S("string") enclosure if not installed.
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
-- Hopefully, use make_gettext_pair from game_intllib if installed.
if minetest.get_modpath("game_intllib") then
gettext, ngettext = gintllib.make_gettext_pair()
end
-- Fill in missing functions if game_intllib is not installed.
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

292
mods/default/nodes.lua Normal file → Executable file

File diff suppressed because it is too large Load Diff

54
mods/default/tools.lua Normal file → Executable file
View File

@ -1,5 +1,9 @@
-- mods/default/tools.lua
-- Load support for game_intllib.
local MP = minetest.get_modpath(minetest.get_current_modname())
local S, NS = dofile(MP .. "/gintllib.lua")
-- The hand
minetest.register_item(":", {
type = "none",
@ -22,7 +26,7 @@ minetest.register_item(":", {
--
minetest.register_tool("default:pick_wood", {
description = "Wooden Pickaxe",
description = S("Wooden Pickaxe"),
inventory_image = "default_tool_woodpick.png",
tool_capabilities = {
full_punch_interval = 1.2,
@ -37,7 +41,7 @@ minetest.register_tool("default:pick_wood", {
})
minetest.register_tool("default:pick_stone", {
description = "Stone Pickaxe",
description = S("Stone Pickaxe"),
inventory_image = "default_tool_stonepick.png",
tool_capabilities = {
full_punch_interval = 1.3,
@ -51,7 +55,7 @@ minetest.register_tool("default:pick_stone", {
})
minetest.register_tool("default:pick_bronze", {
description = "Bronze Pickaxe",
description = S("Bronze Pickaxe"),
inventory_image = "default_tool_bronzepick.png",
tool_capabilities = {
full_punch_interval = 1.0,
@ -65,7 +69,7 @@ minetest.register_tool("default:pick_bronze", {
})
minetest.register_tool("default:pick_steel", {
description = "Steel Pickaxe",
description = S("Steel Pickaxe"),
inventory_image = "default_tool_steelpick.png",
tool_capabilities = {
full_punch_interval = 1.0,
@ -79,7 +83,7 @@ minetest.register_tool("default:pick_steel", {
})
minetest.register_tool("default:pick_mese", {
description = "Mese Pickaxe",
description = S("Mese Pickaxe"),
inventory_image = "default_tool_mesepick.png",
tool_capabilities = {
full_punch_interval = 0.9,
@ -93,7 +97,7 @@ minetest.register_tool("default:pick_mese", {
})
minetest.register_tool("default:pick_diamond", {
description = "Diamond Pickaxe",
description = S("Diamond Pickaxe"),
inventory_image = "default_tool_diamondpick.png",
tool_capabilities = {
full_punch_interval = 0.9,
@ -111,7 +115,7 @@ minetest.register_tool("default:pick_diamond", {
--
minetest.register_tool("default:shovel_wood", {
description = "Wooden Shovel",
description = S("Wooden Shovel"),
inventory_image = "default_tool_woodshovel.png",
wield_image = "default_tool_woodshovel.png^[transformR90",
tool_capabilities = {
@ -127,7 +131,7 @@ minetest.register_tool("default:shovel_wood", {
})
minetest.register_tool("default:shovel_stone", {
description = "Stone Shovel",
description = S("Stone Shovel"),
inventory_image = "default_tool_stoneshovel.png",
wield_image = "default_tool_stoneshovel.png^[transformR90",
tool_capabilities = {
@ -142,7 +146,7 @@ minetest.register_tool("default:shovel_stone", {
})
minetest.register_tool("default:shovel_bronze", {
description = "Bronze Shovel",
description = S("Bronze Shovel"),
inventory_image = "default_tool_bronzeshovel.png",
wield_image = "default_tool_bronzeshovel.png^[transformR90",
tool_capabilities = {
@ -157,7 +161,7 @@ minetest.register_tool("default:shovel_bronze", {
})
minetest.register_tool("default:shovel_steel", {
description = "Steel Shovel",
description = S("Steel Shovel"),
inventory_image = "default_tool_steelshovel.png",
wield_image = "default_tool_steelshovel.png^[transformR90",
tool_capabilities = {
@ -172,7 +176,7 @@ minetest.register_tool("default:shovel_steel", {
})
minetest.register_tool("default:shovel_mese", {
description = "Mese Shovel",
description = S("Mese Shovel"),
inventory_image = "default_tool_meseshovel.png",
wield_image = "default_tool_meseshovel.png^[transformR90",
tool_capabilities = {
@ -187,7 +191,7 @@ minetest.register_tool("default:shovel_mese", {
})
minetest.register_tool("default:shovel_diamond", {
description = "Diamond Shovel",
description = S("Diamond Shovel"),
inventory_image = "default_tool_diamondshovel.png",
wield_image = "default_tool_diamondshovel.png^[transformR90",
tool_capabilities = {
@ -206,7 +210,7 @@ minetest.register_tool("default:shovel_diamond", {
--
minetest.register_tool("default:axe_wood", {
description = "Wooden Axe",
description = S("Wooden Axe"),
inventory_image = "default_tool_woodaxe.png",
tool_capabilities = {
full_punch_interval = 1.0,
@ -221,7 +225,7 @@ minetest.register_tool("default:axe_wood", {
})
minetest.register_tool("default:axe_stone", {
description = "Stone Axe",
description = S("Stone Axe"),
inventory_image = "default_tool_stoneaxe.png",
tool_capabilities = {
full_punch_interval = 1.2,
@ -235,7 +239,7 @@ minetest.register_tool("default:axe_stone", {
})
minetest.register_tool("default:axe_bronze", {
description = "Bronze Axe",
description = S("Bronze Axe"),
inventory_image = "default_tool_bronzeaxe.png",
tool_capabilities = {
full_punch_interval = 1.0,
@ -249,7 +253,7 @@ minetest.register_tool("default:axe_bronze", {
})
minetest.register_tool("default:axe_steel", {
description = "Steel Axe",
description = S("Steel Axe"),
inventory_image = "default_tool_steelaxe.png",
tool_capabilities = {
full_punch_interval = 1.0,
@ -263,7 +267,7 @@ minetest.register_tool("default:axe_steel", {
})
minetest.register_tool("default:axe_mese", {
description = "Mese Axe",
description = S("Mese Axe"),
inventory_image = "default_tool_meseaxe.png",
tool_capabilities = {
full_punch_interval = 0.9,
@ -277,7 +281,7 @@ minetest.register_tool("default:axe_mese", {
})
minetest.register_tool("default:axe_diamond", {
description = "Diamond Axe",
description = S("Diamond Axe"),
inventory_image = "default_tool_diamondaxe.png",
tool_capabilities = {
full_punch_interval = 0.9,
@ -295,7 +299,7 @@ minetest.register_tool("default:axe_diamond", {
--
minetest.register_tool("default:sword_wood", {
description = "Wooden Sword",
description = S("Wooden Sword"),
inventory_image = "default_tool_woodsword.png",
tool_capabilities = {
full_punch_interval = 1,
@ -310,7 +314,7 @@ minetest.register_tool("default:sword_wood", {
})
minetest.register_tool("default:sword_stone", {
description = "Stone Sword",
description = S("Stone Sword"),
inventory_image = "default_tool_stonesword.png",
tool_capabilities = {
full_punch_interval = 1.2,
@ -324,7 +328,7 @@ minetest.register_tool("default:sword_stone", {
})
minetest.register_tool("default:sword_bronze", {
description = "Bronze Sword",
description = S("Bronze Sword"),
inventory_image = "default_tool_bronzesword.png",
tool_capabilities = {
full_punch_interval = 0.8,
@ -338,7 +342,7 @@ minetest.register_tool("default:sword_bronze", {
})
minetest.register_tool("default:sword_steel", {
description = "Steel Sword",
description = S("Steel Sword"),
inventory_image = "default_tool_steelsword.png",
tool_capabilities = {
full_punch_interval = 0.8,
@ -352,7 +356,7 @@ minetest.register_tool("default:sword_steel", {
})
minetest.register_tool("default:sword_mese", {
description = "Mese Sword",
description = S("Mese Sword"),
inventory_image = "default_tool_mesesword.png",
tool_capabilities = {
full_punch_interval = 0.7,
@ -366,7 +370,7 @@ minetest.register_tool("default:sword_mese", {
})
minetest.register_tool("default:sword_diamond", {
description = "Diamond Sword",
description = S("Diamond Sword"),
inventory_image = "default_tool_diamondsword.png",
tool_capabilities = {
full_punch_interval = 0.7,
@ -380,7 +384,7 @@ minetest.register_tool("default:sword_diamond", {
})
minetest.register_tool("default:key", {
description = "Key",
description = S("Key"),
inventory_image = "default_key.png",
groups = {key = 1, not_in_creative_inventory = 1},
stack_max = 1,

8
mods/default/torch.lua Normal file → Executable file
View File

@ -1,3 +1,9 @@
-- default/torch.lua
-- Load support for game_intllib.
local MP = minetest.get_modpath(minetest.get_current_modname())
local S, NS = dofile(MP .. "/gintllib.lua")
local function on_flood(pos, oldnode, newnode)
minetest.add_item(pos, ItemStack("default:torch 1"))
-- Play flame-extinguish sound if liquid is not an 'igniter'
@ -14,7 +20,7 @@ local function on_flood(pos, oldnode, newnode)
end
minetest.register_node("default:torch", {
description = "Torch",
description = S("Torch"),
drawtype = "mesh",
mesh = "torch_floor.obj",
inventory_image = "default_torch_on_floor.png",

14
mods/default/trees.lua Normal file → Executable file
View File

@ -1,3 +1,10 @@
-- default/trees.lua
-- Load support for game_intllib.
local MP = minetest.get_modpath(minetest.get_current_modname())
local S, NS = dofile(MP .. "/gintllib.lua")
local random = math.random
--
@ -560,9 +567,12 @@ function default.sapling_on_place(itemstack, placer, pointed_thing,
interval) then
minetest.record_protection_violation(pos, player_name)
-- Print extra information to explain
-- minetest.chat_send_player(player_name,
-- itemstack:get_definition().description .. " will intersect protection " ..
-- "on growth")
minetest.chat_send_player(player_name,
itemstack:get_definition().description .. " will intersect protection " ..
"on growth")
S("@1 will intersect protection on growth.",
itemstack:get_definition().description))
return itemstack
end

1
mods/doors/depends.txt Normal file → Executable file
View File

@ -1,2 +1,3 @@
default
screwdriver?
game_intllib?

50
mods/doors/gintllib.lua Executable file
View File

@ -0,0 +1,50 @@
-- gintllib.lua
-- should be copied from ../game_intllib/lib/gintllib.lua (2019-05-12)
-- Please note: This is for the default minetest_game mod tree only.
-- For external mods one should make use of the original inttlib mod
-- without interference to the game_intllib mod and it's functions.
-- Fallback functions for when `game_intllib` is not installed.
-- Code released under ../gintllib/LICENSE.md [snoopy (Zweihorn)]
-- Minetest Game Translation with 'game_intllib' (based on 'intllib')
-- Copyright (2019) The Minetest Core & Minetest Game Developers (LGPLv2.1+)
-- Fallback to handle a S("string") enclosure if not installed.
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
-- Hopefully, use make_gettext_pair from game_intllib if installed.
if minetest.get_modpath("game_intllib") then
gettext, ngettext = gintllib.make_gettext_pair()
end
-- Fill in missing functions if game_intllib is not installed.
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

66
mods/doors/init.lua Normal file → Executable file
View File

@ -4,6 +4,11 @@ doors = {}
doors.registered_doors = {}
doors.registered_trapdoors = {}
-- Load support for game_intllib.
local MP = minetest.get_modpath(minetest.get_current_modname())
local S, NS = dofile(MP .. "/gintllib.lua")
local function replace_old_owner_information(pos)
local meta = minetest.get_meta(pos)
local owner = meta:get_string("doors_owner")
@ -71,7 +76,7 @@ end
-- this hidden node is placed on top of the bottom, and prevents
-- nodes from being placed in the top half of the door.
minetest.register_node("doors:hidden", {
description = "Hidden Door Segment",
description = S("Hidden Door Segment"),
-- can't use airlike otherwise falling nodes will turn to entities
-- and will be forever stuck until door is removed.
drawtype = "nodebox",
@ -327,7 +332,7 @@ function doors.register(name, def)
if def.protected then
meta:set_string("owner", pn)
meta:set_string("infotext", "Owned by " .. pn)
meta:set_string("infotext", S("Owned by @1", pn))
end
if not (creative and creative.is_enabled_for and creative.is_enabled_for(pn)) then
@ -401,7 +406,7 @@ function doors.register(name, def)
-- verify placer is owner of lockable door
if owner ~= pname then
minetest.record_protection_violation(pos, pname)
minetest.chat_send_player(pname, "You do not own this locked door.")
minetest.chat_send_player(pname, S("You do not own this locked door."))
return nil
end
@ -449,7 +454,7 @@ end
doors.register("door_wood", {
tiles = {{ name = "doors_door_wood.png", backface_culling = true }},
description = "Wooden Door",
description = S("Wooden Door"),
inventory_image = "doors_item_wood.png",
groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2},
recipe = {
@ -461,7 +466,7 @@ doors.register("door_wood", {
doors.register("door_steel", {
tiles = {{name = "doors_door_steel.png", backface_culling = true}},
description = "Steel Door",
description = S("Steel Door"),
inventory_image = "doors_item_steel.png",
protected = true,
groups = {cracky = 1, level = 2},
@ -477,7 +482,7 @@ doors.register("door_steel", {
doors.register("door_glass", {
tiles = {"doors_door_glass.png"},
description = "Glass Door",
description = S("Glass Door"),
inventory_image = "doors_item_glass.png",
groups = {cracky=3, oddly_breakable_by_hand=3},
sounds = default.node_sound_glass_defaults(),
@ -492,7 +497,7 @@ doors.register("door_glass", {
doors.register("door_obsidian_glass", {
tiles = {"doors_door_obsidian_glass.png"},
description = "Obsidian Glass Door",
description = S("Obsidian Glass Door"),
inventory_image = "doors_item_obsidian_glass.png",
groups = {cracky=3},
sounds = default.node_sound_glass_defaults(),
@ -580,7 +585,7 @@ function doors.register_trapdoor(name, def)
local pn = placer:get_player_name()
local meta = minetest.get_meta(pos)
meta:set_string("owner", pn)
meta:set_string("infotext", "Owned by "..pn)
meta:set_string("infotext", S("Owned by @1", pn))
return (creative and creative.is_enabled_for and creative.is_enabled_for(pn))
end
@ -599,7 +604,7 @@ function doors.register_trapdoor(name, def)
-- verify placer is owner of lockable door
if owner ~= pname then
minetest.record_protection_violation(pos, pname)
minetest.chat_send_player(pname, "You do not own this trapdoor.")
minetest.chat_send_player(pname, S("You do not own this trapdoor."))
return nil
end
@ -642,14 +647,10 @@ function doors.register_trapdoor(name, def)
type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, -6/16, 0.5}
}
def_closed.tiles = {
def.tile_front,
def.tile_front .. '^[transformFY',
def.tile_side,
def.tile_side,
def.tile_side,
def.tile_side
}
def_closed.tiles = {def.tile_front,
def.tile_front .. '^[transformFY',
def.tile_side, def.tile_side,
def.tile_side, def.tile_side}
def_opened.node_box = {
type = "fixed",
@ -659,14 +660,11 @@ function doors.register_trapdoor(name, def)
type = "fixed",
fixed = {-0.5, -0.5, 6/16, 0.5, 0.5, 0.5}
}
def_opened.tiles = {
def.tile_side,
def.tile_side .. '^[transform2',
def.tile_side .. '^[transform3',
def.tile_side .. '^[transform1',
def.tile_front .. '^[transform46',
def.tile_front .. '^[transform6'
}
def_opened.tiles = {def.tile_side, def.tile_side,
def.tile_side .. '^[transform3',
def.tile_side .. '^[transform1',
def.tile_front .. '^[transform46',
def.tile_front .. '^[transform6'}
def_opened.drop = name_closed
def_opened.groups.not_in_creative_inventory = 1
@ -679,7 +677,7 @@ function doors.register_trapdoor(name, def)
end
doors.register_trapdoor("doors:trapdoor", {
description = "Wooden Trapdoor",
description = S("Wooden Trapdoor"),
inventory_image = "doors_trapdoor.png",
wield_image = "doors_trapdoor.png",
tile_front = "doors_trapdoor.png",
@ -688,7 +686,7 @@ doors.register_trapdoor("doors:trapdoor", {
})
doors.register_trapdoor("doors:trapdoor_steel", {
description = "Steel Trapdoor",
description = S("Steel Trapdoor"),
inventory_image = "doors_trapdoor_steel.png",
wield_image = "doors_trapdoor_steel.png",
tile_front = "doors_trapdoor_steel.png",
@ -788,42 +786,42 @@ function doors.register_fencegate(name, def)
minetest.register_craft({
output = name .. "_closed",
recipe = {
{"group:stick", def.material, "group:stick"},
{"group:stick", def.material, "group:stick"}
{"default:stick", def.material, "default:stick"},
{"default:stick", def.material, "default:stick"}
}
})
end
doors.register_fencegate("doors:gate_wood", {
description = "Apple Wood Fence Gate",
description = S("Apple Wood Fence Gate"),
texture = "default_wood.png",
material = "default:wood",
groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2}
})
doors.register_fencegate("doors:gate_acacia_wood", {
description = "Acacia Wood Fence Gate",
description = S("Acacia Wood Fence Gate"),
texture = "default_acacia_wood.png",
material = "default:acacia_wood",
groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2}
})
doors.register_fencegate("doors:gate_junglewood", {
description = "Jungle Wood Fence Gate",
description = S("Jungle Wood Fence Gate"),
texture = "default_junglewood.png",
material = "default:junglewood",
groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2}
})
doors.register_fencegate("doors:gate_pine_wood", {
description = "Pine Wood Fence Gate",
description = S("Pine Wood Fence Gate"),
texture = "default_pine_wood.png",
material = "default:pine_wood",
groups = {choppy = 3, oddly_breakable_by_hand = 2, flammable = 3}
})
doors.register_fencegate("doors:gate_aspen_wood", {
description = "Aspen Wood Fence Gate",
description = S("Aspen Wood Fence Gate"),
texture = "default_aspen_wood.png",
material = "default:aspen_wood",
groups = {choppy = 3, oddly_breakable_by_hand = 2, flammable = 3}

1
mods/dye/depends.txt Normal file → Executable file
View File

@ -0,0 +1 @@
game_intllib?

50
mods/dye/gintllib.lua Executable file
View File

@ -0,0 +1,50 @@
-- gintllib.lua
-- should be copied from ../game_intllib/lib/gintllib.lua (2019-05-12)
-- Please note: This is for the default minetest_game mod tree only.
-- For external mods one should make use of the original inttlib mod
-- without interference to the game_intllib mod and it's functions.
-- Fallback functions for when `game_intllib` is not installed.
-- Code released under ../gintllib/LICENSE.md [snoopy (Zweihorn)]
-- Minetest Game Translation with 'game_intllib' (based on 'intllib')
-- Copyright (2019) The Minetest Core & Minetest Game Developers (LGPLv2.1+)
-- Fallback to handle a S("string") enclosure if not installed.
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
-- Hopefully, use make_gettext_pair from game_intllib if installed.
if minetest.get_modpath("game_intllib") then
gettext, ngettext = gintllib.make_gettext_pair()
end
-- Fill in missing functions if game_intllib is not installed.
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

37
mods/dye/init.lua Normal file → Executable file
View File

@ -1,23 +1,28 @@
dye = {}
-- Load support for game_intllib.
local MP = minetest.get_modpath(minetest.get_current_modname())
local S, NS = dofile(MP .. "/gintllib.lua")
-- Make dye names and descriptions available globally
dye.dyes = {
{"white", "White"},
{"grey", "Grey"},
{"dark_grey", "Dark grey"},
{"black", "Black"},
{"violet", "Violet"},
{"blue", "Blue"},
{"cyan", "Cyan"},
{"dark_green", "Dark green"},
{"green", "Green"},
{"yellow", "Yellow"},
{"brown", "Brown"},
{"orange", "Orange"},
{"red", "Red"},
{"magenta", "Magenta"},
{"pink", "Pink"},
{"white", S("White")},
{"grey", S("Grey")},
{"dark_grey", S("Dark grey")},
{"black", S("Black")},
{"violet", S("Violet")},
{"blue", S("Blue")},
{"cyan", S("Cyan")},
{"dark_green", S("Dark green")},
{"green", S("Green")},
{"yellow", S("Yellow")},
{"brown", S("Brown")},
{"orange", S("Orange")},
{"red", S("Red")},
{"magenta", S("Magenta")},
{"pink", S("Pink")},
}
-- Define items
@ -30,7 +35,7 @@ for _, row in ipairs(dye.dyes) do
minetest.register_craftitem("dye:" .. name, {
inventory_image = "dye_" .. name .. ".png",
description = description .. " Dye",
description = S("@1 Dye", description),
groups = groups
})

8
mods/farming/api.lua Normal file → Executable file
View File

@ -1,3 +1,7 @@
-- Load support for game_intllib.
local MP = minetest.get_modpath(minetest.get_current_modname())
local S, NS = dofile(MP .. "/gintllib.lua")
-- Wear out hoes, place soil
-- TODO Ignore group:flower
@ -78,7 +82,7 @@ farming.register_hoe = function(name, def)
end
-- Check def table
if def.description == nil then
def.description = "Hoe"
def.description = S("Hoe")
end
if def.inventory_image == nil then
def.inventory_image = "unknown_item.png"
@ -251,7 +255,7 @@ farming.register_plant = function(name, def)
-- Check def table
if not def.description then
def.description = "Seed"
def.description = S("Seed")
end
if not def.inventory_image then
def.inventory_image = "unknown_item.png"

1
mods/farming/depends.txt Normal file → Executable file
View File

@ -1,3 +1,4 @@
default
wool
stairs
game_intllib?

50
mods/farming/gintllib.lua Executable file
View File

@ -0,0 +1,50 @@
-- gintllib.lua
-- should be copied from ../game_intllib/lib/gintllib.lua (2019-05-12)
-- Please note: This is for the default minetest_game mod tree only.
-- For external mods one should make use of the original inttlib mod
-- without interference to the game_intllib mod and it's functions.
-- Fallback functions for when `game_intllib` is not installed.
-- Code released under ../gintllib/LICENSE.md [snoopy (Zweihorn)]
-- Minetest Game Translation with 'game_intllib' (based on 'intllib')
-- Copyright (2019) The Minetest Core & Minetest Game Developers (LGPLv2.1+)
-- Fallback to handle a S("string") enclosure if not installed.
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
-- Hopefully, use make_gettext_pair from game_intllib if installed.
if minetest.get_modpath("game_intllib") then
gettext, ngettext = gintllib.make_gettext_pair()
end
-- Fill in missing functions if game_intllib is not installed.
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

16
mods/farming/hoes.lua Normal file → Executable file
View File

@ -1,5 +1,9 @@
-- Load support for game_intllib.
local MP = minetest.get_modpath(minetest.get_current_modname())
local S, NS = dofile(MP .. "/gintllib.lua")
farming.register_hoe(":farming:hoe_wood", {
description = "Wooden Hoe",
description = S("Wooden Hoe"),
inventory_image = "farming_tool_woodhoe.png",
max_uses = 30,
material = "group:wood",
@ -7,14 +11,14 @@ farming.register_hoe(":farming:hoe_wood", {
})
farming.register_hoe(":farming:hoe_stone", {
description = "Stone Hoe",
description = S("Stone Hoe"),
inventory_image = "farming_tool_stonehoe.png",
max_uses = 90,
material = "group:stone"
})
farming.register_hoe(":farming:hoe_steel", {
description = "Steel Hoe",
description = S("Steel Hoe"),
inventory_image = "farming_tool_steelhoe.png",
max_uses = 500,
material = "default:steel_ingot"
@ -26,21 +30,21 @@ farming.register_hoe(":farming:hoe_steel", {
-- release.
farming.register_hoe(":farming:hoe_bronze", {
description = "Bronze Hoe",
description = S("Bronze Hoe"),
inventory_image = "farming_tool_bronzehoe.png",
max_uses = 220,
groups = {not_in_creative_inventory = 1},
})
farming.register_hoe(":farming:hoe_mese", {
description = "Mese Hoe",
description = S("Mese Hoe"),
inventory_image = "farming_tool_mesehoe.png",
max_uses = 350,
groups = {not_in_creative_inventory = 1},
})
farming.register_hoe(":farming:hoe_diamond", {
description = "Diamond Hoe",
description = S("Diamond Hoe"),
inventory_image = "farming_tool_diamondhoe.png",
max_uses = 500,
groups = {not_in_creative_inventory = 1},

15
mods/farming/init.lua Normal file → Executable file
View File

@ -11,10 +11,15 @@ dofile(farming.path .. "/nodes.lua")
dofile(farming.path .. "/hoes.lua")
-- Load support for game_intllib.
local MP = minetest.get_modpath(minetest.get_current_modname())
local S, NS = dofile(MP .. "/gintllib.lua")
-- WHEAT
farming.register_plant("farming:wheat", {
description = "Wheat Seed",
description = S("Wheat Seed"),
paramtype2 = "meshoptions",
inventory_image = "farming_wheat_seed.png",
steps = 8,
@ -26,13 +31,13 @@ farming.register_plant("farming:wheat", {
})
minetest.register_craftitem("farming:flour", {
description = "Flour",
description = S("Flour"),
inventory_image = "farming_flour.png",
groups = {food_flour = 1, flammable = 1},
})
minetest.register_craftitem("farming:bread", {
description = "Bread",
description = S("Bread"),
inventory_image = "farming_bread.png",
on_use = minetest.item_eat(5),
groups = {food_bread = 1, flammable = 2},
@ -55,7 +60,7 @@ minetest.register_craft({
-- Cotton
farming.register_plant("farming:cotton", {
description = "Cotton Seed",
description = S("Cotton Seed"),
inventory_image = "farming_cotton_seed.png",
steps = 8,
minlight = 13,
@ -65,7 +70,7 @@ farming.register_plant("farming:cotton", {
})
minetest.register_craftitem("farming:string", {
description = "String",
description = S("String"),
inventory_image = "farming_string.png",
groups = {flammable = 2},
})

21
mods/farming/nodes.lua Normal file → Executable file
View File

@ -1,3 +1,10 @@
-- farming/nodes.lua
-- Load support for game_intllib.
local MP = minetest.get_modpath(minetest.get_current_modname())
local S, NS = dofile(MP .. "/gintllib.lua")
minetest.override_item("default:dirt", {
soil = {
base = "default:dirt",
@ -39,7 +46,7 @@ minetest.override_item("default:dirt_with_coniferous_litter", {
})
minetest.register_node("farming:soil", {
description = "Soil",
description = S("Soil"),
tiles = {"default_dirt.png^farming_soil.png", "default_dirt.png"},
drop = "default:dirt",
groups = {crumbly=3, not_in_creative_inventory=1, soil=2, grassland = 1, field = 1},
@ -52,7 +59,7 @@ minetest.register_node("farming:soil", {
})
minetest.register_node("farming:soil_wet", {
description = "Wet Soil",
description = S("Wet Soil"),
tiles = {"default_dirt.png^farming_soil_wet.png", "default_dirt.png^farming_soil_wet_side.png"},
drop = "default:dirt",
groups = {crumbly=3, not_in_creative_inventory=1, soil=3, wet = 1, grassland = 1, field = 1},
@ -73,7 +80,7 @@ minetest.override_item("default:desert_sand", {
}
})
minetest.register_node("farming:desert_sand_soil", {
description = "Desert Sand Soil",
description = S("Desert Sand Soil"),
drop = "default:desert_sand",
tiles = {"farming_desert_sand_soil.png", "default_desert_sand.png"},
groups = {crumbly=3, not_in_creative_inventory = 1, falling_node=1, sand=1, soil = 2, desert = 1, field = 1},
@ -86,7 +93,7 @@ minetest.register_node("farming:desert_sand_soil", {
})
minetest.register_node("farming:desert_sand_soil_wet", {
description = "Wet Desert Sand Soil",
description = S("Wet Desert Sand Soil"),
drop = "default:desert_sand",
tiles = {"farming_desert_sand_soil_wet.png", "farming_desert_sand_soil_wet_side.png"},
groups = {crumbly=3, falling_node=1, sand=1, not_in_creative_inventory=1, soil=3, wet = 1, desert = 1, field = 1},
@ -99,7 +106,7 @@ minetest.register_node("farming:desert_sand_soil_wet", {
})
minetest.register_node("farming:straw", {
description = "Straw",
description = S("Straw"),
tiles = {"farming_straw.png"},
is_ground_content = false,
groups = {snappy=3, flammable=4, fall_damage_add_percent=-30},
@ -111,8 +118,8 @@ stairs.register_stair_and_slab(
"farming:straw",
{snappy = 3, flammable = 4},
{"farming_straw.png"},
"Straw Stair",
"Straw Slab",
S("Straw Stair"),
S("Straw Slab"),
default.node_sound_leaves_defaults(),
true
)

1
mods/fire/depends.txt Normal file → Executable file
View File

@ -1 +1,2 @@
default
game_intllib?

50
mods/fire/gintllib.lua Executable file
View File

@ -0,0 +1,50 @@
-- gintllib.lua
-- should be copied from ../game_intllib/lib/gintllib.lua (2019-05-12)
-- Please note: This is for the default minetest_game mod tree only.
-- For external mods one should make use of the original inttlib mod
-- without interference to the game_intllib mod and it's functions.
-- Fallback functions for when `game_intllib` is not installed.
-- Code released under ../gintllib/LICENSE.md [snoopy (Zweihorn)]
-- Minetest Game Translation with 'game_intllib' (based on 'intllib')
-- Copyright (2019) The Minetest Core & Minetest Game Developers (LGPLv2.1+)
-- Fallback to handle a S("string") enclosure if not installed.
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
-- Hopefully, use make_gettext_pair from game_intllib if installed.
if minetest.get_modpath("game_intllib") then
gettext, ngettext = gintllib.make_gettext_pair()
end
-- Fill in missing functions if game_intllib is not installed.
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

32
mods/fire/init.lua Normal file → Executable file
View File

@ -2,6 +2,11 @@
fire = {}
-- Load support for game_intllib.
local MP = minetest.get_modpath(minetest.get_current_modname())
local S, NS = dofile(MP .. "/gintllib.lua")
-- 'Enable fire' setting
local fire_enabled = minetest.settings:get_bool("enable_fire")
@ -82,7 +87,7 @@ minetest.register_node("fire:basic_flame", {
})
minetest.register_node("fire:permanent_flame", {
description = "Permanent Flame",
description = S("Permanent Flame"),
drawtype = "firelike",
tiles = {
{
@ -113,7 +118,7 @@ minetest.register_node("fire:permanent_flame", {
-- Flint and steel
minetest.register_tool("fire:flint_and_steel", {
description = "Flint and Steel",
description = S("Flint and Steel"),
inventory_image = "fire_flint_steel.png",
sound = {breaks = "default_tool_breaks"},
@ -320,7 +325,7 @@ if fire_enabled then
interval = 7,
chance = 12,
catch_up = false,
action = function(pos)
action = function(pos, node, active_object_count, active_object_count_wider)
local p = minetest.find_node_near(pos, 1, {"air"})
if p then
minetest.set_node(p, {name = "fire:basic_flame"})
@ -337,18 +342,17 @@ if fire_enabled then
interval = 5,
chance = 18,
catch_up = false,
action = function(pos)
action = function(pos, node, active_object_count, active_object_count_wider)
local p = minetest.find_node_near(pos, 1, {"group:flammable"})
if not p then
return
end
local flammable_node = minetest.get_node(p)
local def = minetest.registered_nodes[flammable_node.name]
if def.on_burn then
def.on_burn(p)
else
minetest.remove_node(p)
minetest.check_for_falling(p)
if p then
local flammable_node = minetest.get_node(p)
local def = minetest.registered_nodes[flammable_node.name]
if def.on_burn then
def.on_burn(p)
else
minetest.remove_node(p)
minetest.check_for_falling(p)
end
end
end,
})

3
mods/fireflies/depends.txt Normal file → Executable file
View File

@ -1,2 +1,3 @@
default
vessels
vessels
game_intllib?

50
mods/fireflies/gintllib.lua Executable file
View File

@ -0,0 +1,50 @@
-- gintllib.lua
-- should be copied from ../game_intllib/lib/gintllib.lua (2019-05-12)
-- Please note: This is for the default minetest_game mod tree only.
-- For external mods one should make use of the original inttlib mod
-- without interference to the game_intllib mod and it's functions.
-- Fallback functions for when `game_intllib` is not installed.
-- Code released under ../gintllib/LICENSE.md [snoopy (Zweihorn)]
-- Minetest Game Translation with 'game_intllib' (based on 'intllib')
-- Copyright (2019) The Minetest Core & Minetest Game Developers (LGPLv2.1+)
-- Fallback to handle a S("string") enclosure if not installed.
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
-- Hopefully, use make_gettext_pair from game_intllib if installed.
if minetest.get_modpath("game_intllib") then
gettext, ngettext = gintllib.make_gettext_pair()
end
-- Fill in missing functions if game_intllib is not installed.
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

16
mods/fireflies/init.lua Normal file → Executable file
View File

@ -1,6 +1,12 @@
-- firefly
-- Load support for game_intllib.
local MP = minetest.get_modpath(minetest.get_current_modname())
local S, NS = dofile(MP .. "/gintllib.lua")
minetest.register_node("fireflies:firefly", {
description = "Firefly",
description = S("Firefly"),
drawtype = "plantlike",
tiles = {{
name = "fireflies_firefly_animated.png",
@ -47,7 +53,7 @@ minetest.register_node("fireflies:firefly", {
})
minetest.register_node("fireflies:hidden_firefly", {
description = "Hidden Firefly",
description = S("Hidden Firefly"),
drawtype = "airlike",
inventory_image = "fireflies_firefly.png",
wield_image = "fireflies_firefly.png",
@ -84,7 +90,7 @@ minetest.register_node("fireflies:hidden_firefly", {
-- bug net
minetest.register_tool("fireflies:bug_net", {
description = "Bug Net",
description = S("Bug Net"),
inventory_image = "fireflies_bugnet.png",
on_use = function(itemstack, player, pointed_thing)
if not pointed_thing or pointed_thing.type ~= "node" or
@ -113,14 +119,14 @@ minetest.register_craft( {
recipe = {
{"farming:string", "farming:string"},
{"farming:string", "farming:string"},
{"group:stick", ""}
{"default:stick", ""}
}
})
-- firefly in a bottle
minetest.register_node("fireflies:firefly_bottle", {
description = "Firefly in a Bottle",
description = S("Firefly in a Bottle"),
inventory_image = "fireflies_bottle.png",
wield_image = "fireflies_bottle.png",
tiles = {{

1
mods/flowers/depends.txt Normal file → Executable file
View File

@ -1 +1,2 @@
default
game_intllib?

50
mods/flowers/gintllib.lua Executable file
View File

@ -0,0 +1,50 @@
-- gintllib.lua
-- should be copied from ../game_intllib/lib/gintllib.lua (2019-05-12)
-- Please note: This is for the default minetest_game mod tree only.
-- For external mods one should make use of the original inttlib mod
-- without interference to the game_intllib mod and it's functions.
-- Fallback functions for when `game_intllib` is not installed.
-- Code released under ../gintllib/LICENSE.md [snoopy (Zweihorn)]
-- Minetest Game Translation with 'game_intllib' (based on 'intllib')
-- Copyright (2019) The Minetest Core & Minetest Game Developers (LGPLv2.1+)
-- Fallback to handle a S("string") enclosure if not installed.
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
-- Hopefully, use make_gettext_pair from game_intllib if installed.
if minetest.get_modpath("game_intllib") then
gettext, ngettext = gintllib.make_gettext_pair()
end
-- Fill in missing functions if game_intllib is not installed.
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

38
mods/flowers/init.lua Normal file → Executable file
View File

@ -6,10 +6,14 @@
flowers = {}
-- Load support for game_intllib.
local MP = minetest.get_modpath(minetest.get_current_modname())
local S, NS = dofile(MP .. "/gintllib.lua")
-- Map Generation
dofile(minetest.get_modpath("flowers") .. "/mapgen.lua")
dofile(MP .. "/mapgen.lua")
--
@ -46,6 +50,7 @@ local function add_simple_flower(name, desc, box, f_groups)
paramtype = "light",
walkable = false,
buildable_to = true,
stack_max = 99,
groups = f_groups,
sounds = default.node_sound_leaves_defaults(),
selection_box = {
@ -58,49 +63,49 @@ end
flowers.datas = {
{
"rose",
"Red Rose",
S("Red Rose"),
{-2 / 16, -0.5, -2 / 16, 2 / 16, 5 / 16, 2 / 16},
{color_red = 1, flammable = 1}
},
{
"tulip",
"Orange Tulip",
S("Orange Tulip"),
{-2 / 16, -0.5, -2 / 16, 2 / 16, 3 / 16, 2 / 16},
{color_orange = 1, flammable = 1}
},
{
"dandelion_yellow",
"Yellow Dandelion",
S("Yellow Dandelion"),
{-4 / 16, -0.5, -4 / 16, 4 / 16, -2 / 16, 4 / 16},
{color_yellow = 1, flammable = 1}
},
{
"chrysanthemum_green",
"Green Chrysanthemum",
S("Green Chrysanthemum"),
{-4 / 16, -0.5, -4 / 16, 4 / 16, -1 / 16, 4 / 16},
{color_green = 1, flammable = 1}
},
{
"geranium",
"Blue Geranium",
S("Blue Geranium"),
{-2 / 16, -0.5, -2 / 16, 2 / 16, 2 / 16, 2 / 16},
{color_blue = 1, flammable = 1}
},
{
"viola",
"Viola",
S("Viola"),
{-5 / 16, -0.5, -5 / 16, 5 / 16, -1 / 16, 5 / 16},
{color_violet = 1, flammable = 1}
},
{
"dandelion_white",
"White Dandelion",
S("White Dandelion"),
{-5 / 16, -0.5, -5 / 16, 5 / 16, -2 / 16, 5 / 16},
{color_white = 1, flammable = 1}
},
{
"tulip_black",
"Black Tulip",
S("Black Tulip"),
{-2 / 16, -0.5, -2 / 16, 2 / 16, 3 / 16, 2 / 16},
{color_black = 1, flammable = 1}
},
@ -180,7 +185,7 @@ minetest.register_abm({
--
minetest.register_node("flowers:mushroom_red", {
description = "Red Mushroom",
description = S("Red Mushroom"),
tiles = {"flowers_mushroom_red.png"},
inventory_image = "flowers_mushroom_red.png",
wield_image = "flowers_mushroom_red.png",
@ -199,7 +204,7 @@ minetest.register_node("flowers:mushroom_red", {
})
minetest.register_node("flowers:mushroom_brown", {
description = "Brown Mushroom",
description = S("Brown Mushroom"),
tiles = {"flowers_mushroom_brown.png"},
inventory_image = "flowers_mushroom_brown.png",
wield_image = "flowers_mushroom_brown.png",
@ -221,10 +226,8 @@ minetest.register_node("flowers:mushroom_brown", {
-- Mushroom spread and death
function flowers.mushroom_spread(pos, node)
if minetest.get_node_light(pos, 0.5) > 3 then
if minetest.get_node_light(pos, nil) == 15 then
minetest.remove_node(pos)
end
if minetest.get_node_light(pos, nil) == 15 then
minetest.remove_node(pos)
return
end
local positions = minetest.find_nodes_in_area_under_air(
@ -236,7 +239,8 @@ function flowers.mushroom_spread(pos, node)
end
local pos2 = positions[math.random(#positions)]
pos2.y = pos2.y + 1
if minetest.get_node_light(pos2, 0.5) <= 3 then
if minetest.get_node_light(pos, 0.5) <= 3 and
minetest.get_node_light(pos2, 0.5) <= 3 then
minetest.set_node(pos2, {name = node.name})
end
end
@ -267,7 +271,7 @@ minetest.register_alias("mushroom:red_natural", "flowers:mushroom_red")
--
minetest.register_node("flowers:waterlily", {
description = "Waterlily",
description = S("Waterlily"),
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",

1
mods/game_commands/depends.txt Executable file
View File

@ -0,0 +1 @@
game_intllib?

50
mods/game_commands/gintllib.lua Executable file
View File

@ -0,0 +1,50 @@
-- gintllib.lua
-- should be copied from ../game_intllib/lib/gintllib.lua (2019-05-12)
-- Please note: This is for the default minetest_game mod tree only.
-- For external mods one should make use of the original inttlib mod
-- without interference to the game_intllib mod and it's functions.
-- Fallback functions for when `game_intllib` is not installed.
-- Code released under ../gintllib/LICENSE.md [snoopy (Zweihorn)]
-- Minetest Game Translation with 'game_intllib' (based on 'intllib')
-- Copyright (2019) The Minetest Core & Minetest Game Developers (LGPLv2.1+)
-- Fallback to handle a S("string") enclosure if not installed.
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
-- Hopefully, use make_gettext_pair from game_intllib if installed.
if minetest.get_modpath("game_intllib") then
gettext, ngettext = gintllib.make_gettext_pair()
end
-- Fill in missing functions if game_intllib is not installed.
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

13
mods/game_commands/init.lua Normal file → Executable file
View File

@ -1,5 +1,12 @@
-- game_commands
-- Load support for game_intllib.
local MP = minetest.get_modpath(minetest.get_current_modname())
local S, NS = dofile(MP .. "/gintllib.lua")
minetest.register_chatcommand("killme", {
description = "Kill yourself to respawn",
description = S("Kill yourself to respawn"),
func = function(name)
local player = minetest.get_player_by_name(name)
if player then
@ -15,11 +22,11 @@ minetest.register_chatcommand("killme", {
-- There doesn't seem to be a way to get a default spawn pos
-- from the lua API
return false, "No static_spawnpoint defined"
return false, S("No static_spawnpoint defined")
end
else
-- Show error message if used when not logged in, eg: from IRC mod
return false, "You need to be online to be killed!"
return false, S("You need to be online to be killed!")
end
end
})

44
mods/game_intllib/LICENSE.md Executable file
View File

@ -0,0 +1,44 @@
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to <http://unlicense.org/>
- - -
Minetest Game Translation with 'game_intllib' (based on 'intllib')
Copyright (2019) The Minetest Core & Minetest Game Developers (LGPLv2.1+)
This software and all of its parts are distributed under the same license
as the Minetest Game package and/or the above license.
The mod 'game-intllib' and the 'gintllib.lua' file are derived from
the 2018-08-11 release of 'intllib'.
https://github.com/minetest-mods/intllib/releases/tag/20180811
(kaeza released this on 12 Aug 2018)
See https://github.com/minetest-mods/intllib for the original software.
Consult the applicable README.txt files on the respective mod license.
[snoopy (Zweihorn)], 2019-05-07

54
mods/game_intllib/README.md Executable file
View File

@ -0,0 +1,54 @@
# Internationalization Lib for default game mods of the Minetest game
This is 'game_intllib' by [snoopy (Zweihorn)] 2019-05-07
[Fork from 'intllib' by Diego Martínez (kaeza).]
Released under (LGPLv2.1+). See `LICENSE.md` or `license.txt` for details.
'game_intllib' is an attempt at providing internationalization support
for the default game mods only.
This 'game_intllib' internal mod is specifially aimed at default mods
internal to the game in the 'minetest_game' folder.
The original 'intllib' mod is an attempt at providing internationalization
support for external mods (something Minetest currently lacks).
Should you have any comments/suggestions, please post them in the
[forum topic][topic]. For bug reports, use the [bug tracker][bugtracker]
on Github.
## How to use 'intllib' (the original mod)
If you are a regular player looking for translated texts of mods, just
[install][installing_mods] the original 'intllib' mod like any other
one, then enable it in the GUI of the MT client.
## How to use 'game_intllib' (this mod specifically)
The use of this mod is at the deliberations of the Minetest game devs.
The mod tries to detect your language, but since there's currently no
portable way to do this, it tries several alternatives:
* `language` setting in `minetest.conf`.
* `LANGUAGE` environment variable.
* `LANG` environment variable.
* If all else fails, uses `en`.
In any case, the end result should be the [ISO 639-1 Language Code][ISO639-1]
of the desired language.
### Mod developers
If you are a mod developer looking to add internationalization support to
your mod, please use the original 'intllib' mod and see `doc/developer.md`.
### Translators
If you are a translator, see `doc/translator.md`.
[topic]: https://forum.minetest.net/viewtopic.php?id=4929
[bugtracker]: https://github.com/minetest-mods/intllib/issues
[installing_mods]: https://wiki.minetest.net/Installing_mods
[ISO639-1]: https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes

View File

@ -0,0 +1,6 @@
Game internationalization library.
This mod provides a way to internationalize/localize the default game
mods to other languages in an easy way. It was derived from intllib
but instead is aimed at the default minetest_game mod tree only.
One should make use of inttlib for external mods without interference.
See the README file for details.

View File

@ -0,0 +1,62 @@
# Intllib developer documentation
## Enabling internationalization
In order to enable internationalization for your mod, you will need to copy the
file `lib/intllib.lua` into the root directory of your mod, then include this
boilerplate code in files needing localization:
-- Load support for game_intllib.
local MP = minetest.get_modpath(minetest.get_current_modname())
local S, NS = dofile(MP.."/intllib.lua")
You will also need to optionally depend on intllib, to do so add `intllib?`
to an empty line in your `depends.txt`. Also note that if intllib is not
installed, the getter functions are defined so they return the string
unchanged. This is done so you don't have to sprinkle tons of `if`s (or
similar constructs) to check if the lib is actually installed.
Once you have the code in place, you need to mark strings that need
translation. For each translatable string in your sources, use the `S`
function (see above) to return the translated string. For example:
minetest.register_node("mymod:mynode", {
-- Simple string:
description = S("My Fabulous Node"),
-- String with insertions:
description = S("@1 Car", "Blue"),
-- ...
})
The `NS` function is the equivalent of `ngettext`. It should be used when the
string to be translated has singular and plural forms. For example:
-- The first `count` is for `ngettext` to determine which form to use.
-- The second `count` is the actual replacement.
print(NS("You have one item.", "You have @1 items.", count, count))
## Generating and updating catalogs
This is the basic workflow for working with [gettext][gettext]
Each time you have new strings to be translated, you should do the following:
cd /path/to/mod
/path/to/intllib/tools/xgettext.sh file1.lua file2.lua ...
The script will create a directory named `locale` if it doesn't exist yet,
and will generate the file `template.pot` (a template with all the translatable
strings). If you already have translations, the script will proceed to update
all of them with the new strings.
The script passes some options to the real `xgettext` that should be enough
for most cases. You may specify other options if desired:
xgettext.sh -o file.pot --keyword=blargh:4,5 a.lua b.lua ...
NOTE: There's also a Windows batch file `xgettext.bat` for Windows users,
but you will need to install the gettext command line tools separately. See
the top of the file for configuration.
[gettext]: https://www.gnu.org/software/gettext/

View File

@ -0,0 +1,42 @@
# Locale file format
*Note: This document explains the old conf/ini-like file format.
The new interface uses [gettext][gettext] `.po` files.
See [The Format of PO Files][PO-Files] for more information.*
Here's an example for a Spanish locale file (`es.txt`):
# A comment.
# Another comment.
This line is ignored since it has no equals sign.
Hello, World! = Hola, Mundo!
String with\nnewlines = Cadena con\nsaltos de linea
String with an \= equals sign = Cadena con un signo de \= igualdad
Locale (or translation) files are plain text files consisting of lines of the
form `source text = translated text`. The file must reside in the mod's `locale`
subdirectory, and must be named after the two-letter
[ISO 639-1 Language Code][ISO639-1] of the language you want to support.
The translation files should use the UTF-8 encoding.
Lines beginning with a pound sign are comments and are effectively ignored
by the reader. Note that comments only span until the end of the line;
there's no support for multiline comments. Lines without an equals sign are
also ignored.
Characters that are considered "special" can be "escaped" so they are taken
literally. There are also several escape sequences that can be used:
* Any of `#`, `=` can be escaped to take them literally. The `\#`
sequence is useful if your source text begins with `#`.
* The common escape sequences `\n` and `\t`, meaning newline and
horizontal tab respectively.
* The special `\s` escape sequence represents the space character. It
is mainly useful to add leading or trailing spaces to source or
translated texts, as these spaces would be removed otherwise.
[gettext]: https://www.gnu.org/software/gettext
[PO-Files]: https://www.gnu.org/software/gettext/manual/html_node/PO-Files.html
[ISO639-1]: https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes

View File

@ -0,0 +1,20 @@
# Intllib translator documentation
#### New interface
Use your favorite tools to edit the `.po` files.
#### Old interface
To translate an intllib-supporting mod to your desired language, copy the
`locale/template.txt` file to `locale/LANGUAGE.txt` (where `LANGUAGE` is the
[ISO 639-1 Language Code][ISO639-1] of your language.
Open up the new file in your favorite editor, and translate each line putting
the translated text after the equals sign.
See `localefile.md` for more information about the file format.
[gettext]: https://www.gnu.org/software/gettext/
[ISO639-1]: https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes

227
mods/game_intllib/gettext.lua Executable file
View File

@ -0,0 +1,227 @@
-- game_intllib/gettext.lua
local strsub, strrep = string.sub, string.rep
local strmatch, strgsub = string.match, string.gsub
local function trim(str)
return strmatch(str, "^%s*(.-)%s*$")
end
local escapes = { n="\n", r="\r", t="\t" }
local function unescape(str)
return (strgsub(str, "(\\+)([nrt]?)", function(bs, c)
local bsl = #bs
local realbs = strrep("\\", bsl/2)
if bsl%2 == 1 then
c = escapes[c] or c
end
return realbs..c
end))
end
local function parse_po(str)
local state, msgid, msgid_plural, msgstrind
local texts = { }
local lineno = 0
local function perror(msg)
return error(msg.." at line "..lineno)
end
for _, line in ipairs(str:split("\n")) do repeat
lineno = lineno + 1
line = trim(line)
if line == "" or strmatch(line, "^#") then
state, msgid, msgid_plural = nil, nil, nil
break -- continue
end
local mid = strmatch(line, "^%s*msgid%s*\"(.*)\"%s*$")
if mid then
if state == "id" then
return perror("unexpected msgid")
end
state, msgid = "id", unescape(mid)
break -- continue
end
mid = strmatch(line, "^%s*msgid_plural%s*\"(.*)\"%s*$")
if mid then
if state ~= "id" then
return perror("unexpected msgid_plural")
end
state, msgid_plural = "idp", unescape(mid)
break -- continue
end
local ind, mstr = strmatch(line,
"^%s*msgstr([0-9%[%]]*)%s*\"(.*)\"%s*$")
if ind then
if not msgid then
return perror("missing msgid")
elseif ind == "" then
msgstrind = 0
elseif strmatch(ind, "%[[0-9]+%]") then
msgstrind = tonumber(strsub(ind, 2, -2))
else
return perror("malformed msgstr")
end
texts[msgid] = texts[msgid] or { }
if msgid_plural then
texts[msgid_plural] = texts[msgid]
end
texts[msgid][msgstrind] = unescape(mstr)
state = "str"
break -- continue
end
mstr = strmatch(line, "^%s*\"(.*)\"%s*$")
if mstr then
if state == "id" then
msgid = msgid..unescape(mstr)
break -- continue
elseif state == "idp" then
msgid_plural = msgid_plural..unescape(mstr)
break -- continue
elseif state == "str" then
local text = texts[msgid][msgstrind]
texts[msgid][msgstrind] = text..unescape(mstr)
break -- continue
end
end
return perror("malformed line")
-- luacheck: ignore
until true end -- end for
return texts
end
local M = { }
local function warn(msg)
minetest.log("warning", "[game_intllib] "..msg)
end
-- hax!
-- This function converts a C expression to an equivalent Lua expression.
-- It handles enough stuff to parse the `Plural-Forms` header correctly.
-- Note that it assumes the C expression is valid to begin with.
local function compile_plural_forms(str)
local plural = strmatch(str, "plural=([^;]+);?$")
local function replace_ternary(s)
local c, t, f = strmatch(s, "^(.-)%?(.-):(.*)")
if c then
return ("__if("
..replace_ternary(c)
..","..replace_ternary(t)
..","..replace_ternary(f)
..")")
end
return s
end
plural = replace_ternary(plural)
plural = strgsub(plural, "&&", " and ")
plural = strgsub(plural, "||", " or ")
plural = strgsub(plural, "!=", "~=")
plural = strgsub(plural, "!", " not ")
local f, err = loadstring([[
local function __if(c, t, f)
if c and c~=0 then return t else return f end
end
local function __f(n)
return (]]..plural..[[)
end
return (__f(...))
]])
if not f then return nil, err end
local env = { }
env._ENV, env._G = env, env
setfenv(f, env)
return function(n)
local v = f(n)
if type(v) == "boolean" then
-- Handle things like a plain `n != 1`
v = v and 1 or 0
end
return v
end
end
local function parse_headers(str)
local headers = { }
for _, line in ipairs(str:split("\n")) do
local k, v = strmatch(line, "^([^:]+):%s*(.*)")
if k then
headers[k] = v
end
end
return headers
end
local function load_catalog(filename)
local f, data, err
local function bail(msg)
warn(msg..(err and ": " or "")..(err or ""))
return nil
end
f, err = io.open(filename, "rb")
if not f then
return --bail("failed to open catalog")
end
data, err = f:read("*a")
f:close()
if not data then
return bail("failed to read catalog")
end
data, err = parse_po(data)
if not data then
return bail("failed to parse catalog")
end
err = nil
local hdrs = data[""]
if not (hdrs and hdrs[0]) then
return bail("catalog has no headers")
end
hdrs = parse_headers(hdrs[0])
local pf = hdrs["Plural-Forms"]
if not pf then
-- XXX: Is this right? Gettext assumes this if header not present.
pf = "nplurals=2; plural=n != 1"
end
data.plural_index, err = compile_plural_forms(pf)
if not data.plural_index then
return bail("failed to compile plural forms")
end
--warn("loaded: "..filename)
return data
end
function M.load_catalogs(path)
local langs = gintllib.get_detected_languages()
local cats = { }
for _, lang in ipairs(langs) do
local cat = load_catalog(path.."/"..lang..".po")
if cat then
cats[#cats+1] = cat
end
end
return cats
end
return M

183
mods/game_intllib/init.lua Executable file
View File

@ -0,0 +1,183 @@
-- game_intllib/init.lua
gintllib = {
getters = {},
strings = {},
}
local MP = minetest.get_modpath("game_intllib")
dofile(MP .. "/lib.lua")
local LANG = minetest.settings:get("language")
if not (LANG and (LANG ~= "")) then LANG = os.getenv("LANG") end
if not (LANG and (LANG ~= "")) then LANG = "en" end
local INS_CHAR = gintllib.INSERTION_CHAR
local insertion_pattern = "("..INS_CHAR.."?)"..INS_CHAR.."(%(?)(%d+)(%)?)"
local function do_replacements(str, ...)
local args = {...}
-- Outer parens discard extra return values
return (str:gsub(insertion_pattern, function(escape, open, num, close)
if escape == "" then
local replacement = tostring(args[tonumber(num)])
if open == "" then
replacement = replacement..close
end
return replacement
else
return INS_CHAR..open..num..close
end
end))
end
local function make_getter(msgstrs)
return function(s, ...)
local str
if msgstrs then
str = msgstrs[s]
end
if not str or str == "" then
str = s
end
if select("#", ...) == 0 then
return str
end
return do_replacements(str, ...)
end
end
local function Getter(modname)
modname = modname or minetest.get_current_modname()
if not gintllib.getters[modname] then
local msgstr = gintllib.get_strings(modname)
gintllib.getters[modname] = make_getter(msgstr)
end
return gintllib.getters[modname]
end
local strfind, strsub = string.find, string.sub
local langs
local function split(str, sep)
local pos, endp = 1, #str+1
return function()
if (not pos) or pos > endp then return end
local s, e = strfind(str, sep, pos, true)
local part = strsub(str, pos, s and s-1)
pos = e and e + 1
return part
end
end
function gintllib.get_detected_languages()
if langs then return langs end
langs = { }
local function addlang(l)
local sep
langs[#langs+1] = l
sep = strfind(l, ".", 1, true)
if sep then
l = strsub(l, 1, sep-1)
langs[#langs+1] = l
end
sep = strfind(l, "_", 1, true)
if sep then
langs[#langs+1] = strsub(l, 1, sep-1)
end
end
local v
v = minetest.settings:get("language")
if v and v~="" then
addlang(v)
end
v = os.getenv("LANGUAGE")
if v then
for item in split(v, ":") do
langs[#langs+1] = item
end
end
v = os.getenv("LANG")
if v then
addlang(v)
end
langs[#langs+1] = "en"
return langs
end
-- local gettext = dofile(minetest.get_modpath("game_intllib").."/gettext.lua")
local gettext = dofile(MP .. "/gettext.lua")
local function catgettext(catalogs, msgid)
for _, cat in ipairs(catalogs) do
local msgstr = cat and cat[msgid]
if msgstr and msgstr~="" then
local msg = msgstr[0]
return msg~="" and msg or nil
end
end
end
local function catngettext(catalogs, msgid, msgid_plural, n)
n = math.floor(n)
for _, cat in ipairs(catalogs) do
local msgstr = cat and cat[msgid]
if msgstr then
local index = cat.plural_index(n)
local msg = msgstr[index]
return msg~="" and msg or nil
end
end
return n==1 and msgid or msgid_plural
end
local gettext_getters = { }
function gintllib.make_gettext_pair(modname)
modname = modname or minetest.get_current_modname()
if gettext_getters[modname] then
return unpack(gettext_getters[modname])
end
-- Set central locale dir for the minetest_game mod tree instead of:
-- local localedir = minetest.get_modpath(modname).."/locale"
local localedir = minetest.get_modpath("game_intllib").."/locale"
local catalogs = gettext.load_catalogs(localedir)
local getter = Getter(modname)
local function gettext_func(msgid, ...)
local msgstr = (catgettext(catalogs, msgid)
or getter(msgid))
return do_replacements(msgstr, ...)
end
local function ngettext_func(msgid, msgid_plural, n, ...)
local msgstr = (catngettext(catalogs, msgid, msgid_plural, n)
or getter(msgid))
return do_replacements(msgstr, ...)
end
gettext_getters[modname] = { gettext_func, ngettext_func }
return gettext_func, ngettext_func
end
function gintllib.get_strings(modname, langcode)
modname = modname or minetest.get_current_modname()
return gintllib.strings[modname]
end

View File

@ -0,0 +1,10 @@
# Intllib example
This is a simple mod showing how to use intllib.
It defines a test `intltest:test` item whose description is translated
according to the user's language.
Additionally, it demonstrates how to use plural forms by counting the
number of times the item has been used.

View File

@ -0,0 +1 @@
game_intllib?

View File

@ -0,0 +1,50 @@
-- gintllib.lua
-- should be copied from ../game_intllib/lib/gintllib.lua (2019-05-12)
-- Please note: This is for the default minetest_game mod tree only.
-- For external mods one should make use of the original inttlib mod
-- without interference to the game_intllib mod and it's functions.
-- Fallback functions for when `game_intllib` is not installed.
-- Code released under ../gintllib/LICENSE.md [snoopy (Zweihorn)]
-- Minetest Game Translation with 'game_intllib' (based on 'intllib')
-- Copyright (2019) The Minetest Core & Minetest Game Developers (LGPLv2.1+)
-- Fallback to handle a S("string") enclosure if not installed.
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
-- Hopefully, use make_gettext_pair from game_intllib if installed.
if minetest.get_modpath("game_intllib") then
gettext, ngettext = gintllib.make_gettext_pair()
end
-- Fill in missing functions if game_intllib is not installed.
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

View File

@ -0,0 +1,30 @@
-- game_intllib/intltest/init.lua
-- Load support for game_intllib.
local MP = minetest.get_modpath(minetest.get_current_modname())
local S, NS = dofile(MP .. "/intllib.lua")
local use_count = 0
minetest.log("action", S("Hello, world!"))
minetest.register_craftitem("gintltest:test", {
-- Example use of replacements.
-- Translators: @1 is color, @2 is object.
description = S("Test: @1 @2", S("Blue"), S("Car")),
inventory_image = "default_sand.png",
on_use = function(stack, user, pt)
use_count = use_count + 1
-- Example use of `ngettext` function by the NS enclosure.
-- `n` <= 1 gives first phrase. `n` > 1 gives second phrase.
-- First `use_count` is `n` for ngettext to chose the phrase;
-- Second one is actual replacement.
-- Translators: @1 becomes the value of the 2nd use_count.
local message = NS("Item has been used @1 time.",
"Item has been used @1 times.",
use_count, use_count)
minetest.chat_send_player(user:get_player_name(), message)
end,
})

View File

@ -0,0 +1,43 @@
# I18N Test Mod.
# Copyright (C) 2013-2017 Diego Martínez <kaeza@users.sf.net>
# This file is distributed under the same license as the intllib mod.
# Diego Martínez <kaeza@users.sf.net>, 2013-2017.
#
msgid ""
msgstr ""
"Project-Id-Version: I18N Test Mod 0.1.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-02-25 20:40-0300\n"
"PO-Revision-Date: 2017-01-23 17:36-0300\n"
"Last-Translator: Diego Martnez <kaeza@users.sf.net>\n"
"Language-Team: Spanish\n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#: init.lua
msgid "Hello, world!"
msgstr "¡Hola, mundo!"
#. Translators: @1 is color, @2 is object.
#: init.lua
msgid "Blue"
msgstr "Azul"
#: init.lua
msgid "Car"
msgstr "Carro"
#. Translators: @1 is color, @2 is object.
#: init.lua
msgid "Test: @1 @2"
msgstr "Prueba: @2 @1"
#. Translators: @1 is use count.
#: init.lua
msgid "Item has been used @1 time."
msgid_plural "Item has been used @1 times."
msgstr[0] "El objeto ha sido usado @1 vez."
msgstr[1] "El objeto ha sido usado @1 veces."

View File

@ -0,0 +1,44 @@
# 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-02-25 20:40-0300\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"
"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
#: init.lua
msgid "Hello, world!"
msgstr ""
#. Translators: @1 is color, @2 is object.
#: init.lua
msgid "Blue"
msgstr ""
#: init.lua
msgid "Car"
msgstr ""
#. Translators: @1 is color, @2 is object.
#: init.lua
msgid "Test: @1 @2"
msgstr ""
#. Translators: @1 is use count.
#: init.lua
msgid "Item has been used @1 time."
msgid_plural "Item has been used @1 times."
msgstr[0] ""
msgstr[1] ""

68
mods/game_intllib/lib.lua Executable file
View File

@ -0,0 +1,68 @@
-- game_intllib/lib.lua
gintllib = gintllib or {}
local INS_CHAR = "@"
gintllib.INSERTION_CHAR = INS_CHAR
local escapes = {
["\\"] = "\\",
["n"] = "\n",
["s"] = " ",
["t"] = "\t",
["r"] = "\r",
["f"] = "\f",
[INS_CHAR] = INS_CHAR..INS_CHAR,
}
local function unescape(str)
local parts = {}
local n = 1
local function add(s)
parts[n] = s
n = n + 1
end
local start = 1
while true do
local pos = str:find("\\", start, true)
if pos then
add(str:sub(start, pos - 1))
else
add(str:sub(start))
break
end
local c = str:sub(pos + 1, pos + 1)
add(escapes[c] or c)
start = pos + 2
end
return table.concat(parts)
end
local function find_eq(s)
for slashes, pos in s:gmatch("([\\]*)=()") do
if (slashes:len() % 2) == 0 then
return pos - 1
end
end
end
function gintllib.load_strings(filename)
local file, err = io.open(filename, "r")
if not file then
return nil, err
end
local strings = {}
for line in file:lines() do
line = line:trim()
if line ~= "" and line:sub(1, 1) ~= "#" then
local pos = find_eq(line)
if pos then
local msgid = unescape(line:sub(1, pos - 1):trim())
strings[msgid] = unescape(line:sub(pos + 1):trim())
end
end
end
file:close()
return strings
end

View File

@ -0,0 +1,50 @@
-- gintllib.lua
-- should be copied from ../game_intllib/lib/gintllib.lua (2019-05-12)
-- Please note: This is for the default minetest_game mod tree only.
-- For external mods one should make use of the original inttlib mod
-- without interference to the game_intllib mod and it's functions.
-- Fallback functions for when `game_intllib` is not installed.
-- Code released under ../gintllib/LICENSE.md [snoopy (Zweihorn)]
-- Minetest Game Translation with 'game_intllib' (based on 'intllib')
-- Copyright (2019) The Minetest Core & Minetest Game Developers (LGPLv2.1+)
-- Fallback to handle a S("string") enclosure if not installed.
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
-- Hopefully, use make_gettext_pair from game_intllib if installed.
if minetest.get_modpath("game_intllib") then
gettext, ngettext = gintllib.make_gettext_pair()
end
-- Fill in missing functions if game_intllib is not installed.
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

44
mods/game_intllib/license.txt Executable file
View File

@ -0,0 +1,44 @@
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to <http://unlicense.org/>
- - -
Minetest Game Translation with 'game_intllib' (based on 'intllib')
Copyright (2019) The Minetest Core & Minetest Game Developers (LGPLv2.1+)
This software and all of its parts are distributed under the same license
as the Minetest Game package and/or the above license.
The mod 'game-intllib' and the 'gintllib.lua' file are derived from
the 2018-08-11 release of 'intllib'.
https://github.com/minetest-mods/intllib/releases/tag/20180811
(kaeza released this on 12 Aug 2018)
See https://github.com/minetest-mods/intllib for the original software.
Consult the applicable README.txt files on the respective mod license.
[snoopy (Zweihorn)], 2019-05-07

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,144 @@
#! /usr/bin/env lua
-- game_intllib/tools/findtext.lua
local me = arg[0]:gsub(".*[/\\](.*)$", "%1")
local function err(fmt, ...)
io.stderr:write(("%s: %s\n"):format(me, fmt:format(...)))
os.exit(1)
end
local output
local inputs = { }
local lang
local author
local i = 1
local function usage()
print([[
Usage: ]]..me..[[ [OPTIONS] FILE...
Extract translatable strings from the given FILE(s).
Available options:
-h,--help Show this help screen and exit.
-o,--output X Set output file (default: stdout).
-a,--author X Set author.
-l,--lang X Set language name.
]])
os.exit(0)
end
while i <= #arg do
local a = arg[i]
if (a == "-h") or (a == "--help") then
usage()
elseif (a == "-o") or (a == "--output") then
i = i + 1
if i > #arg then
err("missing required argument to `%s'", a)
end
output = arg[i]
elseif (a == "-a") or (a == "--author") then
i = i + 1
if i > #arg then
err("missing required argument to `%s'", a)
end
author = arg[i]
elseif (a == "-l") or (a == "--lang") then
i = i + 1
if i > #arg then
err("missing required argument to `%s'", a)
end
lang = arg[i]
elseif a:sub(1, 1) ~= "-" then
table.insert(inputs, a)
else
err("unrecognized option `%s'", a)
end
i = i + 1
end
if #inputs == 0 then
err("no input files")
end
local outfile = io.stdout
local function printf(fmt, ...)
outfile:write(fmt:format(...))
end
if output then
local e
outfile, e = io.open(output, "w")
if not outfile then
err("error opening file for writing: %s", e)
end
end
if author or lang then
outfile:write("\n")
end
if lang then
printf("# Language: %s\n", lang)
end
if author then
printf("# Author: %s\n", author)
end
if author or lang then
outfile:write("\n")
end
local escapes = {
["\n"] = "\\n",
["="] = "\\=",
["\\"] = "\\\\",
}
local function escape(s)
return s:gsub("[\\\n=]", escapes)
end
local messages = { }
for _, file in ipairs(inputs) do
local infile, e = io.open(file, "r")
if infile then
for line in infile:lines() do
for s in line:gmatch('S%("([^"]*)"') do
table.insert(messages, s)
end
end
infile:close()
else
io.stderr:write(("%s: WARNING: error opening file: %s\n"):format(me, e))
end
end
table.sort(messages)
local last_msg
for _, msg in ipairs(messages) do
if msg ~= last_msg then
printf("%s =\n", escape(msg))
end
last_msg = msg
end
if output then
outfile:close()
end
--[[
TESTS:
S("foo") S("bar")
S("bar")
S("foo")
]]

View File

@ -0,0 +1,133 @@
#! /usr/bin/env lua
-- game_intllib/tools/updatetext.lua
local basedir = ""
if arg[0]:find("[/\\]") then
basedir = arg[0]:gsub("(.*[/\\]).*$", "%1"):gsub("\\", "/")
end
if basedir == "" then basedir = "./" end
-- Required by load_strings()
function string.trim(s) -- luacheck: ignore
return s:gsub("^%s*(.-)%s*$", "%1")
end
dofile(basedir.."/../lib.lua")
local me = arg[0]:gsub(".*[/\\](.*)$", "%1")
local function err(fmt, ...)
io.stderr:write(("%s: %s\n"):format(me, fmt:format(...)))
os.exit(1)
end
local output, outfile, template
local catalogs = { }
local function usage()
print([[
Usage: ]]..me..[[ [OPTIONS] TEMPLATE CATALOG...
Update a catalog with new strings from a template.
Available options:
-h,--help Show this help screen and exit.
-o,--output X Set output file (default: stdout).
Messages in the template that are not on the catalog are added to the
catalog at the end.
This tool also checks messages that are in the catalog but not in the
template, and reports such lines. It's up to the user to remove such
lines, if so desired.
]])
os.exit(0)
end
local i = 1
while i <= #arg do
local a = arg[i]
if (a == "-h") or (a == "--help") then
usage()
elseif (a == "-o") or (a == "--output") then
i = i + 1
if i > #arg then
err("missing required argument to `%s'", a)
end
output = arg[i]
elseif a:sub(1, 1) ~= "-" then
if not template then
template = a
else
table.insert(catalogs, a)
end
else
err("unrecognized option `%s'", a)
end
i = i + 1
end
if not template then
err("no template specified")
elseif #catalogs == 0 then
err("no catalogs specified")
end
local f, e = io.open(template, "r")
if not f then
err("error opening template: %s", e)
end
local escapes = { ["\n"] = "\\n", ["="] = "\\=", ["\\"] = "\\\\", }
local function escape(s)
return s:gsub("[\\\n=]", escapes)
end
if output then
outfile, e = io.open(output, "w")
if not outfile then
err("error opening file for writing: %s", e)
end
end
local template_msgs = intllib.load_strings(template)
for _, file in ipairs(catalogs) do
print("Processing: "..file)
local catalog_msgs = intllib.load_strings(file)
local dirty_lines = { }
if catalog_msgs then
-- Add new entries from template.
for k in pairs(template_msgs) do
if not catalog_msgs[k] then
print("NEW: "..k)
table.insert(dirty_lines, escape(k).." =")
end
end
-- Check for old messages.
for k, v in pairs(catalog_msgs) do
if not template_msgs[k] then
print("OLD: "..k)
table.insert(dirty_lines, "OLD: "..escape(k).." = "..escape(v))
end
end
if #dirty_lines > 0 then
local outf
outf, e = io.open(file, "a+")
if outf then
outf:write("\n")
for _, line in ipairs(dirty_lines) do
outf:write(line)
outf:write("\n")
end
outf:close()
else
io.stderr:write(("%s: WARNING: cannot write: %s\n"):format(me, e))
end
end
else
io.stderr:write(("%s: WARNING: could not load catalog\n"):format(me))
end
end

View File

@ -0,0 +1,35 @@
@echo off
setlocal
set me=%~n0
rem # -- game_intllib/tools/xgettext.bat
rem # Uncomment the following line if gettext is not in your PATH.
rem # Value must be absolute and end in a backslash.
rem set gtprefix=C:\path\to\gettext\bin\
if "%1" == "" (
echo Usage: %me% FILE... 1>&2
exit 1
)
set xgettext=%gtprefix%xgettext.exe
set msgmerge=%gtprefix%msgmerge.exe
md locale > nul 2>&1
echo Generating template... 1>&2
echo %xgettext% --from-code=UTF-8 -kS -kNS:1,2 -k_ -o game_intllib/locale/template.pot %*
%xgettext% --from-code=UTF-8 -kS -kNS:1,2 -k_ -o game_intllib/locale/template.pot %*
if %ERRORLEVEL% neq 0 goto done
cd game_intllib/locale
for %%f in (*.po) do (
echo Updating %%f... 1>&2
%msgmerge% --update %%f template.pot
)
echo DONE! 1>&2
:done

View File

@ -0,0 +1,30 @@
#! /bin/bash
# -- game_intllib/tools/xgettext.sh
me=$(basename "${BASH_SOURCE[0]}");
if [[ $# -lt 1 ]]; then
echo "Usage: $me FILE..." >&2;
exit 1;
fi
GLOCALE="./game_intllib/locale/"
mkdir -p ${GLOCALE};
echo "Generating template in ${GLOCALE} folder..." >&2;
xgettext --from-code=UTF-8 \
--keyword=S \
--keyword=NS:1,2 \
--keyword=N_ \
--add-comments='Translators:' \
--add-location=file \
-o ${GLOCALE}template.pot \
"$@" \
|| exit;
find ${GLOCALE} -name '*.po' -type f | while read -r file; do
echo "Updating $file..." >&2;
msgmerge --update "$file" ${GLOCALE}template.pot;
done
echo "DONE!" >&2;

2
mods/map/depends.txt Normal file → Executable file
View File

@ -1,3 +1,5 @@
default
dye
creative?
game_intllib?

50
mods/map/gintllib.lua Executable file
View File

@ -0,0 +1,50 @@
-- gintllib.lua
-- should be copied from ../game_intllib/lib/gintllib.lua (2019-05-12)
-- Please note: This is for the default minetest_game mod tree only.
-- For external mods one should make use of the original inttlib mod
-- without interference to the game_intllib mod and it's functions.
-- Fallback functions for when `game_intllib` is not installed.
-- Code released under ../gintllib/LICENSE.md [snoopy (Zweihorn)]
-- Minetest Game Translation with 'game_intllib' (based on 'intllib')
-- Copyright (2019) The Minetest Core & Minetest Game Developers (LGPLv2.1+)
-- Fallback to handle a S("string") enclosure if not installed.
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
-- Hopefully, use make_gettext_pair from game_intllib if installed.
if minetest.get_modpath("game_intllib") then
gettext, ngettext = gintllib.make_gettext_pair()
end
-- Fill in missing functions if game_intllib is not installed.
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

9
mods/map/init.lua Normal file → Executable file
View File

@ -3,6 +3,11 @@
map = {}
-- Load support for game_intllib.
local MP = minetest.get_modpath(minetest.get_current_modname())
local S, NS = dofile(MP .. "/gintllib.lua")
-- Cache creative mode setting
local creative_mode_cache = minetest.settings:get_bool("creative_mode")
@ -49,7 +54,7 @@ minetest.after(5.3, cyclic_update)
-- Mapping kit item
minetest.register_craftitem("map:mapping_kit", {
description = "Mapping Kit\nUse with 'Minimap' key",
description = S("Mapping Kit\nUse with 'Minimap' key"),
inventory_image = "map_mapping_kit.png",
stack_max = 1,
groups = {flammable = 3},
@ -65,7 +70,7 @@ minetest.register_craftitem("map:mapping_kit", {
minetest.register_craft({
output = "map:mapping_kit",
recipe = {
{"default:glass", "default:paper", "group:stick"},
{"default:glass", "default:paper", "default:stick"},
{"default:steel_ingot", "default:paper", "default:steel_ingot"},
{"group:wood", "default:paper", "dye:black"},
}

1
mods/screwdriver/depends.txt Executable file
View File

@ -0,0 +1 @@
game_intllib?

50
mods/screwdriver/gintllib.lua Executable file
View File

@ -0,0 +1,50 @@
-- gintllib.lua
-- should be copied from ../game_intllib/lib/gintllib.lua (2019-05-12)
-- Please note: This is for the default minetest_game mod tree only.
-- For external mods one should make use of the original inttlib mod
-- without interference to the game_intllib mod and it's functions.
-- Fallback functions for when `game_intllib` is not installed.
-- Code released under ../gintllib/LICENSE.md [snoopy (Zweihorn)]
-- Minetest Game Translation with 'game_intllib' (based on 'intllib')
-- Copyright (2019) The Minetest Core & Minetest Game Developers (LGPLv2.1+)
-- Fallback to handle a S("string") enclosure if not installed.
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
-- Hopefully, use make_gettext_pair from game_intllib if installed.
if minetest.get_modpath("game_intllib") then
gettext, ngettext = gintllib.make_gettext_pair()
end
-- Fill in missing functions if game_intllib is not installed.
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
mods/screwdriver/init.lua Normal file → Executable file
View File

@ -1,5 +1,10 @@
screwdriver = {}
-- Load support for game_intllib.
local MP = minetest.get_modpath(minetest.get_current_modname())
local S, NS = dofile(MP .. "/gintllib.lua")
screwdriver.ROTATE_FACE = 1
screwdriver.ROTATE_AXIS = 2
screwdriver.disallow = function(pos, node, user, mode, new_param2)
@ -144,7 +149,7 @@ end
-- Screwdriver
minetest.register_tool("screwdriver:screwdriver", {
description = "Screwdriver (left-click rotates face, right-click rotates axis)",
description = S("Screwdriver (left-click rotates face, right-click rotates axis)"),
inventory_image = "screwdriver.png",
on_use = function(itemstack, user, pointed_thing)
screwdriver.handler(itemstack, user, pointed_thing, screwdriver.ROTATE_FACE, 200)

2
mods/sethome/depends.txt Executable file
View File

@ -0,0 +1,2 @@
game_intllib?

50
mods/sethome/gintllib.lua Executable file
View File

@ -0,0 +1,50 @@
-- gintllib.lua
-- should be copied from ../game_intllib/lib/gintllib.lua (2019-05-12)
-- Please note: This is for the default minetest_game mod tree only.
-- For external mods one should make use of the original inttlib mod
-- without interference to the game_intllib mod and it's functions.
-- Fallback functions for when `game_intllib` is not installed.
-- Code released under ../gintllib/LICENSE.md [snoopy (Zweihorn)]
-- Minetest Game Translation with 'game_intllib' (based on 'intllib')
-- Copyright (2019) The Minetest Core & Minetest Game Developers (LGPLv2.1+)
-- Fallback to handle a S("string") enclosure if not installed.
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
-- Hopefully, use make_gettext_pair from game_intllib if installed.
if minetest.get_modpath("game_intllib") then
gettext, ngettext = gintllib.make_gettext_pair()
end
-- Fill in missing functions if game_intllib is not installed.
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

19
mods/sethome/init.lua Normal file → Executable file
View File

@ -1,6 +1,11 @@
sethome = {}
-- Load support for game_intllib.
local MP = minetest.get_modpath(minetest.get_current_modname())
local S, NS = dofile(MP .. "/gintllib.lua")
local homes_file = minetest.get_worldpath() .. "/homes"
local homepos = {}
@ -68,30 +73,30 @@ sethome.go = function(name)
end
minetest.register_privilege("home", {
description = "Can use /sethome and /home",
description = S("Can use /sethome and /home"),
give_to_singleplayer = false
})
minetest.register_chatcommand("home", {
description = "Teleport you to your home point",
description = S("Teleport you to your home point"),
privs = {home = true},
func = function(name)
if sethome.go(name) then
return true, "Teleported to home!"
return true, S("Teleported to home!")
end
return false, "Set a home using /sethome"
return false, S("Set a home using /sethome")
end,
})
minetest.register_chatcommand("sethome", {
description = "Set your home point",
description = S("Set your home point"),
privs = {home = true},
func = function(name)
name = name or "" -- fallback to blank name if nil
local player = minetest.get_player_by_name(name)
if player and sethome.set(name, player:get_pos()) then
return true, "Home set!"
return true, S("Home set!")
end
return false, "Player not found!"
return false, S("Player not found!")
end,
})

1
mods/stairs/depends.txt Normal file → Executable file
View File

@ -1 +1,2 @@
default
game_intllib?

50
mods/stairs/gintllib.lua Executable file
View File

@ -0,0 +1,50 @@
-- gintllib.lua
-- should be copied from ../game_intllib/lib/gintllib.lua (2019-05-12)
-- Please note: This is for the default minetest_game mod tree only.
-- For external mods one should make use of the original inttlib mod
-- without interference to the game_intllib mod and it's functions.
-- Fallback functions for when `game_intllib` is not installed.
-- Code released under ../gintllib/LICENSE.md [snoopy (Zweihorn)]
-- Minetest Game Translation with 'game_intllib' (based on 'intllib')
-- Copyright (2019) The Minetest Core & Minetest Game Developers (LGPLv2.1+)
-- Fallback to handle a S("string") enclosure if not installed.
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
-- Hopefully, use make_gettext_pair from game_intllib if installed.
if minetest.get_modpath("game_intllib") then
gettext, ngettext = gintllib.make_gettext_pair()
end
-- Fill in missing functions if game_intllib is not installed.
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

160
mods/stairs/init.lua Normal file → Executable file
View File

@ -6,6 +6,10 @@
stairs = {}
-- Load support for game_intllib.
local MP = minetest.get_modpath(minetest.get_current_modname())
local S, NS = dofile(MP .. "/gintllib.lua")
-- Register aliases for new pine node names
@ -308,7 +312,7 @@ function stairs.register_stair_inner(subname, recipeitem, groups, images,
local new_groups = table.copy(groups)
new_groups.stair = 1
minetest.register_node(":stairs:stair_inner_" .. subname, {
description = "Inner " .. description,
description = S("Inner @1", description),
drawtype = "nodebox",
tiles = stair_images,
paramtype = "light",
@ -389,7 +393,7 @@ function stairs.register_stair_outer(subname, recipeitem, groups, images,
local new_groups = table.copy(groups)
new_groups.stair = 1
minetest.register_node(":stairs:stair_outer_" .. subname, {
description = "Outer " .. description,
description = S("Outer @1", description),
drawtype = "nodebox",
tiles = stair_images,
paramtype = "light",
@ -462,8 +466,8 @@ stairs.register_stair_and_slab(
"default:wood",
{choppy = 2, oddly_breakable_by_hand = 2, flammable = 2},
{"default_wood.png"},
"Wooden Stair",
"Wooden Slab",
S("Wooden Stair"),
S("Wooden Slab"),
default.node_sound_wood_defaults(),
false
)
@ -473,8 +477,8 @@ stairs.register_stair_and_slab(
"default:junglewood",
{choppy = 2, oddly_breakable_by_hand = 2, flammable = 2},
{"default_junglewood.png"},
"Jungle Wood Stair",
"Jungle Wood Slab",
S("Jungle Wood Stair"),
S("Jungle Wood Slab"),
default.node_sound_wood_defaults(),
false
)
@ -484,8 +488,8 @@ stairs.register_stair_and_slab(
"default:pine_wood",
{choppy = 3, oddly_breakable_by_hand = 2, flammable = 3},
{"default_pine_wood.png"},
"Pine Wood Stair",
"Pine Wood Slab",
S("Pine Wood Stair"),
S("Pine Wood Slab"),
default.node_sound_wood_defaults(),
false
)
@ -495,8 +499,8 @@ stairs.register_stair_and_slab(
"default:acacia_wood",
{choppy = 2, oddly_breakable_by_hand = 2, flammable = 2},
{"default_acacia_wood.png"},
"Acacia Wood Stair",
"Acacia Wood Slab",
S("Acacia Wood Stair"),
S("Acacia Wood Slab"),
default.node_sound_wood_defaults(),
false
)
@ -506,8 +510,8 @@ stairs.register_stair_and_slab(
"default:aspen_wood",
{choppy = 3, oddly_breakable_by_hand = 2, flammable = 3},
{"default_aspen_wood.png"},
"Aspen Wood Stair",
"Aspen Wood Slab",
S("Aspen Wood Stair"),
S("Aspen Wood Slab"),
default.node_sound_wood_defaults(),
false
)
@ -517,8 +521,8 @@ stairs.register_stair_and_slab(
"default:stone",
{cracky = 3},
{"default_stone.png"},
"Stone Stair",
"Stone Slab",
S("Stone Stair"),
S("Stone Slab"),
default.node_sound_stone_defaults(),
true
)
@ -528,8 +532,8 @@ stairs.register_stair_and_slab(
"default:cobble",
{cracky = 3},
{"default_cobble.png"},
"Cobblestone Stair",
"Cobblestone Slab",
S("Cobblestone Stair"),
S("Cobblestone Slab"),
default.node_sound_stone_defaults(),
true
)
@ -539,8 +543,8 @@ stairs.register_stair_and_slab(
"default:mossycobble",
{cracky = 3},
{"default_mossycobble.png"},
"Mossy Cobblestone Stair",
"Mossy Cobblestone Slab",
S("Mossy Cobblestone Stair"),
S("Mossy Cobblestone Slab"),
default.node_sound_stone_defaults(),
true
)
@ -550,8 +554,8 @@ stairs.register_stair_and_slab(
"default:stonebrick",
{cracky = 2},
{"default_stone_brick.png"},
"Stone Brick Stair",
"Stone Brick Slab",
S("Stone Brick Stair"),
S("Stone Brick Slab"),
default.node_sound_stone_defaults(),
false
)
@ -561,8 +565,8 @@ stairs.register_stair_and_slab(
"default:stone_block",
{cracky = 2},
{"default_stone_block.png"},
"Stone Block Stair",
"Stone Block Slab",
S("Stone Block Stair"),
S("Stone Block Slab"),
default.node_sound_stone_defaults(),
true
)
@ -572,8 +576,8 @@ stairs.register_stair_and_slab(
"default:desert_stone",
{cracky = 3},
{"default_desert_stone.png"},
"Desert Stone Stair",
"Desert Stone Slab",
S("Desert Stone Stair"),
S("Desert Stone Slab"),
default.node_sound_stone_defaults(),
true
)
@ -583,8 +587,8 @@ stairs.register_stair_and_slab(
"default:desert_cobble",
{cracky = 3},
{"default_desert_cobble.png"},
"Desert Cobblestone Stair",
"Desert Cobblestone Slab",
S("Desert Cobblestone Stair"),
S("Desert Cobblestone Slab"),
default.node_sound_stone_defaults(),
true
)
@ -594,8 +598,8 @@ stairs.register_stair_and_slab(
"default:desert_stonebrick",
{cracky = 2},
{"default_desert_stone_brick.png"},
"Desert Stone Brick Stair",
"Desert Stone Brick Slab",
S("Desert Stone Brick Stair"),
S("Desert Stone Brick Slab"),
default.node_sound_stone_defaults(),
false
)
@ -605,8 +609,8 @@ stairs.register_stair_and_slab(
"default:desert_stone_block",
{cracky = 2},
{"default_desert_stone_block.png"},
"Desert Stone Block Stair",
"Desert Stone Block Slab",
S("Desert Stone Block Stair"),
S("Desert Stone Block Slab"),
default.node_sound_stone_defaults(),
true
)
@ -616,8 +620,8 @@ stairs.register_stair_and_slab(
"default:sandstone",
{crumbly = 1, cracky = 3},
{"default_sandstone.png"},
"Sandstone Stair",
"Sandstone Slab",
S("Sandstone Stair"),
S("Sandstone Slab"),
default.node_sound_stone_defaults(),
true
)
@ -627,8 +631,8 @@ stairs.register_stair_and_slab(
"default:sandstonebrick",
{cracky = 2},
{"default_sandstone_brick.png"},
"Sandstone Brick Stair",
"Sandstone Brick Slab",
S("Sandstone Brick Stair"),
S("Sandstone Brick Slab"),
default.node_sound_stone_defaults(),
false
)
@ -638,8 +642,8 @@ stairs.register_stair_and_slab(
"default:sandstone_block",
{cracky = 2},
{"default_sandstone_block.png"},
"Sandstone Block Stair",
"Sandstone Block Slab",
S("Sandstone Block Stair"),
S("Sandstone Block Slab"),
default.node_sound_stone_defaults(),
true
)
@ -649,8 +653,8 @@ stairs.register_stair_and_slab(
"default:desert_sandstone",
{crumbly = 1, cracky = 3},
{"default_desert_sandstone.png"},
"Desert Sandstone Stair",
"Desert Sandstone Slab",
S("Desert Sandstone Stair"),
S("Desert Sandstone Slab"),
default.node_sound_stone_defaults(),
true
)
@ -660,8 +664,8 @@ stairs.register_stair_and_slab(
"default:desert_sandstone_brick",
{cracky = 2},
{"default_desert_sandstone_brick.png"},
"Desert Sandstone Brick Stair",
"Desert Sandstone Brick Slab",
S("Desert Sandstone Brick Stair"),
S("Desert Sandstone Brick Slab"),
default.node_sound_stone_defaults(),
false
)
@ -671,8 +675,8 @@ stairs.register_stair_and_slab(
"default:desert_sandstone_block",
{cracky = 2},
{"default_desert_sandstone_block.png"},
"Desert Sandstone Block Stair",
"Desert Sandstone Block Slab",
S("Desert Sandstone Block Stair"),
S("Desert Sandstone Block Slab"),
default.node_sound_stone_defaults(),
true
)
@ -682,8 +686,8 @@ stairs.register_stair_and_slab(
"default:silver_sandstone",
{crumbly = 1, cracky = 3},
{"default_silver_sandstone.png"},
"Silver Sandstone Stair",
"Silver Sandstone Slab",
S("Silver Sandstone Stair"),
S("Silver Sandstone Slab"),
default.node_sound_stone_defaults(),
true
)
@ -693,8 +697,8 @@ stairs.register_stair_and_slab(
"default:silver_sandstone_brick",
{cracky = 2},
{"default_silver_sandstone_brick.png"},
"Silver Sandstone Brick Stair",
"Silver Sandstone Brick Slab",
S("Silver Sandstone Brick Stair"),
S("Silver Sandstone Brick Slab"),
default.node_sound_stone_defaults(),
false
)
@ -704,8 +708,8 @@ stairs.register_stair_and_slab(
"default:silver_sandstone_block",
{cracky = 2},
{"default_silver_sandstone_block.png"},
"Silver Sandstone Block Stair",
"Silver Sandstone Block Slab",
S("Silver Sandstone Block Stair"),
S("Silver Sandstone Block Slab"),
default.node_sound_stone_defaults(),
true
)
@ -715,8 +719,8 @@ stairs.register_stair_and_slab(
"default:obsidian",
{cracky = 1, level = 2},
{"default_obsidian.png"},
"Obsidian Stair",
"Obsidian Slab",
S("Obsidian Stair"),
S("Obsidian Slab"),
default.node_sound_stone_defaults(),
true
)
@ -726,8 +730,8 @@ stairs.register_stair_and_slab(
"default:obsidianbrick",
{cracky = 1, level = 2},
{"default_obsidian_brick.png"},
"Obsidian Brick Stair",
"Obsidian Brick Slab",
S("Obsidian Brick Stair"),
S("Obsidian Brick Slab"),
default.node_sound_stone_defaults(),
false
)
@ -737,8 +741,8 @@ stairs.register_stair_and_slab(
"default:obsidian_block",
{cracky = 1, level = 2},
{"default_obsidian_block.png"},
"Obsidian Block Stair",
"Obsidian Block Slab",
S("Obsidian Block Stair"),
S("Obsidian Block Slab"),
default.node_sound_stone_defaults(),
true
)
@ -748,8 +752,8 @@ stairs.register_stair_and_slab(
"default:brick",
{cracky = 3},
{"default_brick.png"},
"Brick Stair",
"Brick Slab",
S("Brick Stair"),
S("Brick Slab"),
default.node_sound_stone_defaults(),
false
)
@ -759,8 +763,8 @@ stairs.register_stair_and_slab(
"default:steelblock",
{cracky = 1, level = 2},
{"default_steel_block.png"},
"Steel Block Stair",
"Steel Block Slab",
S("Steel Block Stair"),
S("Steel Block Slab"),
default.node_sound_metal_defaults(),
true
)
@ -770,8 +774,8 @@ stairs.register_stair_and_slab(
"default:tinblock",
{cracky = 1, level = 2},
{"default_tin_block.png"},
"Tin Block Stair",
"Tin Block Slab",
S("Tin Block Stair"),
S("Tin Block Slab"),
default.node_sound_metal_defaults(),
true
)
@ -781,8 +785,8 @@ stairs.register_stair_and_slab(
"default:copperblock",
{cracky = 1, level = 2},
{"default_copper_block.png"},
"Copper Block Stair",
"Copper Block Slab",
S("Copper Block Stair"),
S("Copper Block Slab"),
default.node_sound_metal_defaults(),
true
)
@ -792,8 +796,8 @@ stairs.register_stair_and_slab(
"default:bronzeblock",
{cracky = 1, level = 2},
{"default_bronze_block.png"},
"Bronze Block Stair",
"Bronze Block Slab",
S("Bronze Block Stair"),
S("Bronze Block Slab"),
default.node_sound_metal_defaults(),
true
)
@ -803,8 +807,8 @@ stairs.register_stair_and_slab(
"default:goldblock",
{cracky = 1},
{"default_gold_block.png"},
"Gold Block Stair",
"Gold Block Slab",
S("Gold Block Stair"),
S("Gold Block Slab"),
default.node_sound_metal_defaults(),
true
)
@ -814,8 +818,8 @@ stairs.register_stair_and_slab(
"default:ice",
{cracky = 3, cools_lava = 1, slippery = 3},
{"default_ice.png"},
"Ice Stair",
"Ice Slab",
S("Ice Stair"),
S("Ice Slab"),
default.node_sound_glass_defaults(),
true
)
@ -825,8 +829,8 @@ stairs.register_stair_and_slab(
"default:snowblock",
{crumbly = 3, cools_lava = 1, snowy = 1},
{"default_snow.png"},
"Snow Block Stair",
"Snow Block Slab",
S("Snow Block Stair"),
S("Snow Block Slab"),
default.node_sound_snow_defaults(),
true
)
@ -840,7 +844,7 @@ stairs.register_stair(
{"stairs_glass_split.png", "default_glass.png",
"stairs_glass_stairside.png^[transformFX", "stairs_glass_stairside.png",
"default_glass.png", "stairs_glass_split.png"},
"Glass Stair",
S("Glass Stair"),
default.node_sound_glass_defaults(),
false
)
@ -850,7 +854,7 @@ stairs.register_slab(
"default:glass",
{cracky = 3},
{"default_glass.png", "default_glass.png", "stairs_glass_split.png"},
"Glass Slab",
S("Glass Slab"),
default.node_sound_glass_defaults(),
false
)
@ -862,7 +866,7 @@ stairs.register_stair_inner(
{"stairs_glass_stairside.png^[transformR270", "default_glass.png",
"stairs_glass_stairside.png^[transformFX", "default_glass.png",
"default_glass.png", "stairs_glass_stairside.png"},
"Glass Stair",
S("Glass Stair"),
default.node_sound_glass_defaults(),
false
)
@ -874,7 +878,7 @@ stairs.register_stair_outer(
{"stairs_glass_stairside.png^[transformR90", "default_glass.png",
"stairs_glass_outer_stairside.png", "stairs_glass_stairside.png",
"stairs_glass_stairside.png^[transformR90","stairs_glass_outer_stairside.png"},
"Glass Stair",
S("Glass Stair"),
default.node_sound_glass_defaults(),
false
)
@ -886,7 +890,7 @@ stairs.register_stair(
{"stairs_obsidian_glass_split.png", "default_obsidian_glass.png",
"stairs_obsidian_glass_stairside.png^[transformFX", "stairs_obsidian_glass_stairside.png",
"default_obsidian_glass.png", "stairs_obsidian_glass_split.png"},
"Obsidian Glass Stair",
S("Obsidian Glass Stair"),
default.node_sound_glass_defaults(),
false
)
@ -896,7 +900,7 @@ stairs.register_slab(
"default:obsidian_glass",
{cracky = 3},
{"default_obsidian_glass.png", "default_obsidian_glass.png", "stairs_obsidian_glass_split.png"},
"Obsidian Glass Slab",
S("Obsidian Glass Slab"),
default.node_sound_glass_defaults(),
false
)
@ -908,7 +912,7 @@ stairs.register_stair_inner(
{"stairs_obsidian_glass_stairside.png^[transformR270", "default_obsidian_glass.png",
"stairs_obsidian_glass_stairside.png^[transformFX", "default_obsidian_glass.png",
"default_obsidian_glass.png", "stairs_obsidian_glass_stairside.png"},
"Obsidian Glass Stair",
S("Obsidian Glass Stair"),
default.node_sound_glass_defaults(),
false
)
@ -920,7 +924,7 @@ stairs.register_stair_outer(
{"stairs_obsidian_glass_stairside.png^[transformR90", "default_obsidian_glass.png",
"stairs_obsidian_glass_outer_stairside.png", "stairs_obsidian_glass_stairside.png",
"stairs_obsidian_glass_stairside.png^[transformR90","stairs_obsidian_glass_outer_stairside.png"},
"Obsidian Glass Stair",
S("Obsidian Glass Stair"),
default.node_sound_glass_defaults(),
false
)

2
mods/tnt/depends.txt Normal file → Executable file
View File

@ -1,3 +1,3 @@
default
fire
game_intllib?

50
mods/tnt/gintllib.lua Executable file
View File

@ -0,0 +1,50 @@
-- gintllib.lua
-- should be copied from ../game_intllib/lib/gintllib.lua (2019-05-12)
-- Please note: This is for the default minetest_game mod tree only.
-- For external mods one should make use of the original inttlib mod
-- without interference to the game_intllib mod and it's functions.
-- Fallback functions for when `game_intllib` is not installed.
-- Code released under ../gintllib/LICENSE.md [snoopy (Zweihorn)]
-- Minetest Game Translation with 'game_intllib' (based on 'intllib')
-- Copyright (2019) The Minetest Core & Minetest Game Developers (LGPLv2.1+)
-- Fallback to handle a S("string") enclosure if not installed.
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
-- Hopefully, use make_gettext_pair from game_intllib if installed.
if minetest.get_modpath("game_intllib") then
gettext, ngettext = gintllib.make_gettext_pair()
end
-- Fill in missing functions if game_intllib is not installed.
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

11
mods/tnt/init.lua Normal file → Executable file
View File

@ -1,5 +1,10 @@
tnt = {}
-- Load support for game_intllib.
local MP = minetest.get_modpath(minetest.get_current_modname())
local S, NS = dofile(MP .. "/gintllib.lua")
-- Default to enabled when in singleplayer
local enable_tnt = minetest.settings:get_bool("enable_tnt")
if enable_tnt == nil then
@ -422,7 +427,7 @@ minetest.register_node("tnt:boom", {
})
minetest.register_node("tnt:gunpowder", {
description = "Gun Powder",
description = S("Gun Powder"),
drawtype = "raillike",
paramtype = "light",
is_ground_content = false,
@ -547,7 +552,7 @@ minetest.register_craft({
})
minetest.register_craftitem("tnt:tnt_stick", {
description = "TNT Stick",
description = S("TNT Stick"),
inventory_image = "tnt_tnt_stick.png",
groups = {flammable = 5},
})
@ -675,6 +680,6 @@ end
tnt.register_tnt({
name = "tnt:tnt",
description = "TNT",
description = S("TNT"),
radius = tnt_radius,
})

1
mods/vessels/depends.txt Normal file → Executable file
View File

@ -1 +1,2 @@
default
game_intllib?

50
mods/vessels/gintllib.lua Executable file
View File

@ -0,0 +1,50 @@
-- gintllib.lua
-- should be copied from ../game_intllib/lib/gintllib.lua (2019-05-12)
-- Please note: This is for the default minetest_game mod tree only.
-- For external mods one should make use of the original inttlib mod
-- without interference to the game_intllib mod and it's functions.
-- Fallback functions for when `game_intllib` is not installed.
-- Code released under ../gintllib/LICENSE.md [snoopy (Zweihorn)]
-- Minetest Game Translation with 'game_intllib' (based on 'intllib')
-- Copyright (2019) The Minetest Core & Minetest Game Developers (LGPLv2.1+)
-- Fallback to handle a S("string") enclosure if not installed.
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
-- Hopefully, use make_gettext_pair from game_intllib if installed.
if minetest.get_modpath("game_intllib") then
gettext, ngettext = gintllib.make_gettext_pair()
end
-- Fill in missing functions if game_intllib is not installed.
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

Some files were not shown because too many files have changed in this diff Show More