Added Intllib support (thanks H4mlet) also few 0.4.16 function updates

This commit is contained in:
TenPlus1 2018-03-12 10:40:39 +00:00
parent a3eef3fcc9
commit 6862241cb0
7 changed files with 200 additions and 30 deletions

View File

@ -1,3 +1,4 @@
default
sethome?
creative?
intllib?

View File

@ -1,6 +1,11 @@
-- Load support for intllib.
local MP = minetest.get_modpath(minetest.get_current_modname())
local S, NS = dofile(MP .. "/intllib.lua")
-- static spawn position
local statspawn = (minetest.setting_get_pos("static_spawnpoint") or {x = 0, y = 12, z = 0})
local statspawn = minetest.string_to_pos(minetest.settings:get("static_spawnpoint"))
or {x = 0, y = 12, z = 0}
local home_gui = {}
-- get_formspec
@ -10,16 +15,16 @@ home_gui.get_formspec = function(player)
.. default.gui_bg
.. default.gui_bg_img
.. default.gui_slots
.. "button[0,0;2,0.5;main;Back]"
.. "button_exit[0,1.5;2,0.5;home_gui_set;Set Home]"
.. "button_exit[2,1.5;2,0.5;home_gui_go;Go Home]"
.. "button_exit[4,1.5;2,0.5;home_gui_spawn;Spawn]"
.. "button[0,0;2,0.5;main;" .. S("Back") .. "]"
.. "button_exit[0,1.5;2,0.5;home_gui_set;" .. S("Set Home") .. "]"
.. "button_exit[2,1.5;2,0.5;home_gui_go;Go " .. S("Home") .. "]"
.. "button_exit[4,1.5;2,0.5;home_gui_spawn;" .. S("Spawn") .. "]"
local home = sethome.get( player:get_player_name() )
if home then
formspec = formspec
.."label[2.5,-0.2;Home set to:]"
.."label[2.5,-0.2;" .. S("Home set to:") .. "]"
.."label[2.5,0.4;".. minetest.pos_to_string(vector.round(home)) .. "]"
end
@ -28,7 +33,7 @@ end
-- add inventory_plus page when player joins
minetest.register_on_joinplayer(function(player)
inventory_plus.register_button(player,"home_gui","Home Pos")
inventory_plus.register_button(player,"home_gui",S("Home Pos"))
end)
-- what to do when we press da buttons
@ -50,7 +55,7 @@ end)
-- spawn command
minetest.register_chatcommand("spawn", {
description = "Go to Spawn",
description = S("Go to Spawn"),
privs = {home = true},
func = function(name)
local player = minetest.get_player_by_name(name)

View File

@ -10,6 +10,10 @@ Edited by TenPlus1 (19th October 2016)
]]--
-- Load support for intllib.
local MP = minetest.get_modpath(minetest.get_current_modname())
local S, NS = dofile(MP .. "/intllib.lua")
-- compatibility with older minetest versions
if not rawget(_G, "creative") then
local creative = {}
@ -18,9 +22,9 @@ end
-- check for new creative addition
local addition = ""
if creative.formspec_add then
creative.formspec_add = "button[5.4,4.2;2.65,0.3;main;Back]"
creative.formspec_add = "button[5.4,4.2;2.65,0.3;main;" .. S("Back") .. "]"
else
addition = "button[5.4,4.2;2.65,0.3;main;Back]"
addition = "button[5.4,4.2;2.65,0.3;main;" .. S("Back") .. "]"
end
-- expose api
@ -92,12 +96,12 @@ inventory_plus.get_formspec = function(player, page)
if page == "craft" then
if not player:get_inventory() then
print ("[Inventory Plus] NO PLAYER INVENTORY FOUND!")
print (S("[Inventory Plus] NO PLAYER INVENTORY FOUND!"))
return
end
formspec = formspec
.. "button[0,1;2,0.5;main;Back]"
.. "button[0,1;2,0.5;main;" .. S("Back") .. "]"
.. "list[current_player;craftpreview;7,1;1,1;]"
.. "list[current_player;craft;3,0;3,3;]"
.. "listring[current_name;craft]"
@ -143,11 +147,11 @@ end
-- register_on_joinplayer
minetest.register_on_joinplayer(function(player)
inventory_plus.register_button(player,"craft", "Craft")
inventory_plus.register_button(player,"craft", S("Craft"))
if minetest.settings:get_bool("creative_mode")
or minetest.check_player_privs(player:get_player_name(), {creative = true}) then
inventory_plus.register_button(player, "creative_prev", "Creative")
inventory_plus.register_button(player, "creative_prev", S("Creative"))
end
minetest.after(1, function()
@ -197,6 +201,6 @@ minetest.register_alias("inventory_plus:workbench", "default:wood")
-- Add Home GUI
if minetest.get_modpath("sethome") and sethome then
print ("sethome found, adding home_gui to inventory plus")
dofile(minetest.get_modpath("inventory_plus") .. "/home_gui.lua")
print (S("sethome found, adding home_gui to inventory plus"))
dofile(MP .. "/home_gui.lua")
end

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

63
locale/it.po Normal file
View File

@ -0,0 +1,63 @@
# ITALIAN LOCALIZATION FILE FOR INVENTORY PLUS.
# Copyright (C) 2018 Brett O'Donnell http://cornernote.github.io
# This file is distributed under the same license as the Inventory Plus package.
# Hamlet <h4mlet@riseup.net>, 2018.
#
msgid ""
msgstr ""
"Project-Id-Version: Inventory Plus\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-03-03 23:17+0100\n"
"PO-Revision-Date: 2018-03-03 23:00+0100\n"
"Last-Translator: Hamlet <h4mlet@riseup.net>\n"
"Language-Team: \n"
"Language: it\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"
"X-Generator: Poedit 1.6.10\n"
#: init.lua home_gui.lua
msgid "Back"
msgstr "Indietro"
#: init.lua
msgid "NO PLAYER INVENTORY FOUND!"
msgstr "L'INVENTARIO DEL PERSONAGGIO NON È STATO TROVATO"
#: init.lua
msgid "Craft"
msgstr "Assemb."
#: init.lua
msgid "Creative"
msgstr "Creativa"
#: init.lua
msgid "sethome found, adding home_gui to inventory plus"
msgstr "sethome trovato, home_gui viene aggiunta a Inventory Plus"
#: home_gui.lua
msgid "Set Home"
msgstr "Imp. casa"
#: home_gui.lua
msgid "Go Home"
msgstr "And. casa"
#: home_gui.lua
msgid "Spawn"
msgstr "Origine"
#: home_gui.lua
msgid "Home set to:"
msgstr "Casa impostata a:"
#: home_gui.lua
msgid "Home Pos"
msgstr "Pos. casa"
#: home_gui.lua
msgid "Go to Spawn"
msgstr "And. origine"

62
locale/template.pot Normal file
View File

@ -0,0 +1,62 @@
# LANGUAGE_NAME LOCALIZATION FILE FOR INVENTORY PLUS.
# Copyright (C) 2018 Brett O'Donnell http://cornernote.github.io
# This file is distributed under the same license as the Inventory Plus package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: Inventory Plus\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-03-03 23:17+0100\n"
"PO-Revision-Date: \n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: init.lua home_gui.lua
msgid "Back"
msgstr ""
#: init.lua
msgid "NO PLAYER INVENTORY FOUND!"
msgstr ""
#: init.lua
msgid "Craft"
msgstr ""
#: init.lua
msgid "Creative"
msgstr ""
#: init.lua
msgid "sethome found, adding home_gui to inventory plus"
msgstr ""
#: home_gui.lua
msgid "Set Home"
msgstr ""
#: home_gui.lua
msgid "Go Home"
msgstr ""
#: home_gui.lua
msgid "Spawn"
msgstr ""
#: home_gui.lua
msgid "Home set to:"
msgstr ""
#: home_gui.lua
msgid "Home Pos"
msgstr ""
#: home_gui.lua
msgid "Go to Spawn"
msgstr ""

View File

@ -2,30 +2,20 @@
written by CornerNode
updated by TenPlus1
## Description
Allows additional formspec buttons to be added to the player inventory.
## Features
- Allows additional formspec buttons to be added to the player inventory screen.
- These are processed by your own mod, they can show other formspec screens, or perform in game functionality.
- Adds support for refill/trash to Creative Inventory.
- Adds support for Creative Inventory.
- Intllib support for languages (thanks to H4mlet)
## Project Resources
* [Home](http://cornernote.github.io/minetest-inventory_plus/)
* [Download](https://github.com/cornernote/minetest-inventory_plus/archive/master.zip)
* [Project](https://github.com/cornernote/minetest-inventory_plus)
* [Download](https://github.com/tenplus1/inventory_plus/archive/master.zip)
* [Project](https://github.com/tenplus1/inventory_plus)
* [Forum](http://forum.minetest.net/viewtopic.php?t=6204)
* [Bower](https://minetest-bower.herokuapp.com/mods/inventory_plus)
## Support
- Does this README need improvement? Go ahead and [suggest a change](https://github.com/cornernote/minetest-inventory_plus/edit/master/README.md).
- Found a bug, or need help using this project? Check the [open issues](https://github.com/cornernote/minetest-inventory_plus/issues) or [create an issue](https://github.com/cornernote/minetest-inventory_plus/issues/new).
## About