added intllib support and malay translation (thanks MuhdNurHidayat)

This commit is contained in:
TenPlus1 2018-02-19 10:28:21 +00:00
parent 86c46b3ecf
commit 85e9ffc80a
5 changed files with 178 additions and 11 deletions

View File

@ -1,2 +1,3 @@
mobs
lucky_block?
intllib?

View File

@ -1,4 +1,8 @@
-- intllib
local MP = minetest.get_modpath(minetest.get_current_modname())
local S, NS = dofile(MP .. "/intllib.lua")
-- rideable horse
mobs:register_mob("mob_horse:horse", {
@ -141,7 +145,7 @@ mobs:spawn({
day_toggle = true,
})
mobs:register_egg("mob_horse:horse", "Horse", "wool_brown.png", 1)
mobs:register_egg("mob_horse:horse", S("Horse"), "wool_brown.png", 1)
-- horseshoe helper function
@ -164,21 +168,21 @@ local apply_shoes = function(name, itemstack, obj, shoes, speed, jump, reverse)
ent.accel = speed
ent.shoed = shoes
minetest.chat_send_player(name, "Horse shoes fitted -"
.. " speed: " .. speed
.. " , jump height: " .. jump
.. " , stop speed: " .. reverse)
minetest.chat_send_player(name, S("Horse shoes fitted -")
.. S(" speed: ") .. speed
.. S(" , jump height: ") .. jump
.. S(" , stop speed: ") .. reverse)
itemstack:take_item() ; return itemstack
else
minetest.chat_send_player(name, "Horse shoes only work on horses!")
minetest.chat_send_player(name, S("Horse shoes only work on horses!"))
end
end
-- steel horseshoes
minetest.register_craftitem(":mobs:horseshoe_steel", {
description = "Steel HorseShoes (use on horse to apply)",
description = S("Steel HorseShoes (use on horse to apply)"),
inventory_image = "mobs_horseshoe_steel.png",
on_use = function(itemstack, user, pointed_thing)
return apply_shoes(user:get_player_name(), itemstack, pointed_thing,
@ -197,7 +201,7 @@ minetest.register_craft({
-- bronze horseshoes
minetest.register_craftitem(":mobs:horseshoe_bronze", {
description = "Bronze HorseShoes (use on horse to apply)",
description = S("Bronze HorseShoes (use on horse to apply)"),
inventory_image = "mobs_horseshoe_bronze.png",
on_use = function(itemstack, user, pointed_thing)
return apply_shoes(user:get_player_name(), itemstack, pointed_thing,
@ -216,7 +220,7 @@ minetest.register_craft({
-- mese horseshoes
minetest.register_craftitem(":mobs:horseshoe_mese", {
description = "Mese HorseShoes (use on horse to apply)",
description = S("Mese HorseShoes (use on horse to apply)"),
inventory_image = "mobs_horseshoe_mese.png",
on_use = function(itemstack, user, pointed_thing)
return apply_shoes(user:get_player_name(), itemstack, pointed_thing,
@ -235,7 +239,7 @@ minetest.register_craft({
-- diamond horseshoes
minetest.register_craftitem(":mobs:horseshoe_diamond", {
description = "Diamond HorseShoes (use on horse to apply)",
description = S("Diamond HorseShoes (use on horse to apply)"),
inventory_image = "mobs_horseshoe_diamond.png",
on_use = function(itemstack, user, pointed_thing)
return apply_shoes(user:get_player_name(), itemstack, pointed_thing,

45
intllib.lua Normal file
View File

@ -0,0 +1,45 @@
-- Fallback functions for when `intllib` is not installed.
-- Code released under Unlicense <http://unlicense.org>.
-- Get the latest version of this file at:
-- https://raw.githubusercontent.com/minetest-mods/intllib/master/lib/intllib.lua
local function format(str, ...)
local args = { ... }
local function repl(escape, open, num, close)
if escape == "" then
local replacement = tostring(args[tonumber(num)])
if open == "" then
replacement = replacement..close
end
return replacement
else
return "@"..open..num..close
end
end
return (str:gsub("(@?)@(%(?)(%d+)(%)?)", repl))
end
local gettext, ngettext
if minetest.get_modpath("intllib") then
if intllib.make_gettext_pair then
-- New method using gettext.
gettext, ngettext = intllib.make_gettext_pair()
else
-- Old method using text files.
gettext = intllib.Getter()
end
end
-- Fill in missing functions.
gettext = gettext or function(msgid, ...)
return format(msgid, ...)
end
ngettext = ngettext or function(msgid, msgid_plural, n, ...)
return format(n==1 and msgid or msgid_plural, ...)
end
return gettext, ngettext

59
locale/ms.po Normal file
View File

@ -0,0 +1,59 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-02-06 00:07+0800\n"
"PO-Revision-Date: 2018-02-06 00:14+0800\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 2.0.6\n"
"Last-Translator: MuhdNurHidayat (MNH48) <mnh48mail@gmail.com>\n"
"Plural-Forms: nplurals=1; plural=0;\n"
"Language: ms\n"
#: init.lua
msgid "Horse"
msgstr "Kuda"
#: init.lua
msgid "Horse shoes fitted -"
msgstr "Ladam telah dipasang pada kuda -"
#: init.lua
msgid " speed: "
msgstr " kelajuan: "
#: init.lua
msgid " , jump height: "
msgstr " , ketinggian lompat: "
#: init.lua
msgid " , stop speed: "
msgstr " , kelajuan berhenti: "
#: init.lua
msgid "Horse shoes only work on horses!"
msgstr "Ladam hanya boleh dipakaikan pada kuda!"
#: init.lua
msgid "Steel HorseShoes (use on horse to apply)"
msgstr "Ladam Kuda Keluli (guna pada kuda untuk pakaikan ia)"
#: init.lua
msgid "Bronze HorseShoes (use on horse to apply)"
msgstr "Ladam Kuda Gangsa (guna pada kuda untuk pakaikan ia)"
#: init.lua
msgid "Mese HorseShoes (use on horse to apply)"
msgstr "Ladam Kuda Mese (guna pada kuda untuk pakaikan ia)"
#: init.lua
msgid "Diamond HorseShoes (use on horse to apply)"
msgstr "Ladam Kuda Intan (guna pada kuda untuk pakaikan ia)"

58
locale/template.pot Normal file
View File

@ -0,0 +1,58 @@
# 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: 2018-02-06 00:07+0800\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"
#: init.lua
msgid "Horse"
msgstr ""
#: init.lua
msgid "Horse shoes fitted -"
msgstr ""
#: init.lua
msgid " speed: "
msgstr ""
#: init.lua
msgid " , jump height: "
msgstr ""
#: init.lua
msgid " , stop speed: "
msgstr ""
#: init.lua
msgid "Horse shoes only work on horses!"
msgstr ""
#: init.lua
msgid "Steel HorseShoes (use on horse to apply)"
msgstr ""
#: init.lua
msgid "Bronze HorseShoes (use on horse to apply)"
msgstr ""
#: init.lua
msgid "Mese HorseShoes (use on horse to apply)"
msgstr ""
#: init.lua
msgid "Diamond HorseShoes (use on horse to apply)"
msgstr ""