Lançamento inicial
parent
9256dcdc2b
commit
81fe34c87f
|
@ -0,0 +1,25 @@
|
||||||
|
API para mod MyMenu v1.0.0
|
||||||
|
|
||||||
|
|
||||||
|
### Métodos Básicos
|
||||||
|
* `mymenu.register_button(field, label)` : Registrar um botao na aba Config do menu
|
||||||
|
|
||||||
|
* `mymenu.register_tr(func)` : Metodo de tradução instantanea cujos argumentos são `(lang_code, string)`
|
||||||
|
|
||||||
|
### Exemplo de código
|
||||||
|
|
||||||
|
```lua
|
||||||
|
-- Registrar metodo de tradução instantanea
|
||||||
|
mymenu.register_tr(function(lang, string) return string end)
|
||||||
|
|
||||||
|
-- Registrar botao
|
||||||
|
mymenu.register_button("mymenu:abrir_menu", "Idioma")
|
||||||
|
|
||||||
|
-- Receber botao do inventario
|
||||||
|
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||||
|
if fields["mymenu:abrir_menu"] then
|
||||||
|
acessar_menu_idiomas(player)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
```
|
||||||
|
|
|
@ -0,0 +1,165 @@
|
||||||
|
GNU LESSER GENERAL PUBLIC LICENSE
|
||||||
|
Version 3, 29 June 2007
|
||||||
|
|
||||||
|
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
|
||||||
|
This version of the GNU Lesser General Public License incorporates
|
||||||
|
the terms and conditions of version 3 of the GNU General Public
|
||||||
|
License, supplemented by the additional permissions listed below.
|
||||||
|
|
||||||
|
0. Additional Definitions.
|
||||||
|
|
||||||
|
As used herein, "this License" refers to version 3 of the GNU Lesser
|
||||||
|
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
||||||
|
General Public License.
|
||||||
|
|
||||||
|
"The Library" refers to a covered work governed by this License,
|
||||||
|
other than an Application or a Combined Work as defined below.
|
||||||
|
|
||||||
|
An "Application" is any work that makes use of an interface provided
|
||||||
|
by the Library, but which is not otherwise based on the Library.
|
||||||
|
Defining a subclass of a class defined by the Library is deemed a mode
|
||||||
|
of using an interface provided by the Library.
|
||||||
|
|
||||||
|
A "Combined Work" is a work produced by combining or linking an
|
||||||
|
Application with the Library. The particular version of the Library
|
||||||
|
with which the Combined Work was made is also called the "Linked
|
||||||
|
Version".
|
||||||
|
|
||||||
|
The "Minimal Corresponding Source" for a Combined Work means the
|
||||||
|
Corresponding Source for the Combined Work, excluding any source code
|
||||||
|
for portions of the Combined Work that, considered in isolation, are
|
||||||
|
based on the Application, and not on the Linked Version.
|
||||||
|
|
||||||
|
The "Corresponding Application Code" for a Combined Work means the
|
||||||
|
object code and/or source code for the Application, including any data
|
||||||
|
and utility programs needed for reproducing the Combined Work from the
|
||||||
|
Application, but excluding the System Libraries of the Combined Work.
|
||||||
|
|
||||||
|
1. Exception to Section 3 of the GNU GPL.
|
||||||
|
|
||||||
|
You may convey a covered work under sections 3 and 4 of this License
|
||||||
|
without being bound by section 3 of the GNU GPL.
|
||||||
|
|
||||||
|
2. Conveying Modified Versions.
|
||||||
|
|
||||||
|
If you modify a copy of the Library, and, in your modifications, a
|
||||||
|
facility refers to a function or data to be supplied by an Application
|
||||||
|
that uses the facility (other than as an argument passed when the
|
||||||
|
facility is invoked), then you may convey a copy of the modified
|
||||||
|
version:
|
||||||
|
|
||||||
|
a) under this License, provided that you make a good faith effort to
|
||||||
|
ensure that, in the event an Application does not supply the
|
||||||
|
function or data, the facility still operates, and performs
|
||||||
|
whatever part of its purpose remains meaningful, or
|
||||||
|
|
||||||
|
b) under the GNU GPL, with none of the additional permissions of
|
||||||
|
this License applicable to that copy.
|
||||||
|
|
||||||
|
3. Object Code Incorporating Material from Library Header Files.
|
||||||
|
|
||||||
|
The object code form of an Application may incorporate material from
|
||||||
|
a header file that is part of the Library. You may convey such object
|
||||||
|
code under terms of your choice, provided that, if the incorporated
|
||||||
|
material is not limited to numerical parameters, data structure
|
||||||
|
layouts and accessors, or small macros, inline functions and templates
|
||||||
|
(ten or fewer lines in length), you do both of the following:
|
||||||
|
|
||||||
|
a) Give prominent notice with each copy of the object code that the
|
||||||
|
Library is used in it and that the Library and its use are
|
||||||
|
covered by this License.
|
||||||
|
|
||||||
|
b) Accompany the object code with a copy of the GNU GPL and this license
|
||||||
|
document.
|
||||||
|
|
||||||
|
4. Combined Works.
|
||||||
|
|
||||||
|
You may convey a Combined Work under terms of your choice that,
|
||||||
|
taken together, effectively do not restrict modification of the
|
||||||
|
portions of the Library contained in the Combined Work and reverse
|
||||||
|
engineering for debugging such modifications, if you also do each of
|
||||||
|
the following:
|
||||||
|
|
||||||
|
a) Give prominent notice with each copy of the Combined Work that
|
||||||
|
the Library is used in it and that the Library and its use are
|
||||||
|
covered by this License.
|
||||||
|
|
||||||
|
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
||||||
|
document.
|
||||||
|
|
||||||
|
c) For a Combined Work that displays copyright notices during
|
||||||
|
execution, include the copyright notice for the Library among
|
||||||
|
these notices, as well as a reference directing the user to the
|
||||||
|
copies of the GNU GPL and this license document.
|
||||||
|
|
||||||
|
d) Do one of the following:
|
||||||
|
|
||||||
|
0) Convey the Minimal Corresponding Source under the terms of this
|
||||||
|
License, and the Corresponding Application Code in a form
|
||||||
|
suitable for, and under terms that permit, the user to
|
||||||
|
recombine or relink the Application with a modified version of
|
||||||
|
the Linked Version to produce a modified Combined Work, in the
|
||||||
|
manner specified by section 6 of the GNU GPL for conveying
|
||||||
|
Corresponding Source.
|
||||||
|
|
||||||
|
1) Use a suitable shared library mechanism for linking with the
|
||||||
|
Library. A suitable mechanism is one that (a) uses at run time
|
||||||
|
a copy of the Library already present on the user's computer
|
||||||
|
system, and (b) will operate properly with a modified version
|
||||||
|
of the Library that is interface-compatible with the Linked
|
||||||
|
Version.
|
||||||
|
|
||||||
|
e) Provide Installation Information, but only if you would otherwise
|
||||||
|
be required to provide such information under section 6 of the
|
||||||
|
GNU GPL, and only to the extent that such information is
|
||||||
|
necessary to install and execute a modified version of the
|
||||||
|
Combined Work produced by recombining or relinking the
|
||||||
|
Application with a modified version of the Linked Version. (If
|
||||||
|
you use option 4d0, the Installation Information must accompany
|
||||||
|
the Minimal Corresponding Source and Corresponding Application
|
||||||
|
Code. If you use option 4d1, you must provide the Installation
|
||||||
|
Information in the manner specified by section 6 of the GNU GPL
|
||||||
|
for conveying Corresponding Source.)
|
||||||
|
|
||||||
|
5. Combined Libraries.
|
||||||
|
|
||||||
|
You may place library facilities that are a work based on the
|
||||||
|
Library side by side in a single library together with other library
|
||||||
|
facilities that are not Applications and are not covered by this
|
||||||
|
License, and convey such a combined library under terms of your
|
||||||
|
choice, if you do both of the following:
|
||||||
|
|
||||||
|
a) Accompany the combined library with a copy of the same work based
|
||||||
|
on the Library, uncombined with any other library facilities,
|
||||||
|
conveyed under the terms of this License.
|
||||||
|
|
||||||
|
b) Give prominent notice with the combined library that part of it
|
||||||
|
is a work based on the Library, and explaining where to find the
|
||||||
|
accompanying uncombined form of the same work.
|
||||||
|
|
||||||
|
6. Revised Versions of the GNU Lesser General Public License.
|
||||||
|
|
||||||
|
The Free Software Foundation may publish revised and/or new versions
|
||||||
|
of the GNU Lesser General Public License from time to time. Such new
|
||||||
|
versions will be similar in spirit to the present version, but may
|
||||||
|
differ in detail to address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the
|
||||||
|
Library as you received it specifies that a certain numbered version
|
||||||
|
of the GNU Lesser General Public License "or any later version"
|
||||||
|
applies to it, you have the option of following the terms and
|
||||||
|
conditions either of that published version or of any later version
|
||||||
|
published by the Free Software Foundation. If the Library as you
|
||||||
|
received it does not specify a version number of the GNU Lesser
|
||||||
|
General Public License, you may choose any version of the GNU Lesser
|
||||||
|
General Public License ever published by the Free Software Foundation.
|
||||||
|
|
||||||
|
If the Library as you received it specifies that a proxy can decide
|
||||||
|
whether future versions of the GNU Lesser General Public License shall
|
||||||
|
apply, that proxy's public statement of acceptance of any version is
|
||||||
|
permanent authorization for you to choose that version for the
|
||||||
|
Library.
|
23
README.md
23
README.md
|
@ -1 +1,22 @@
|
||||||
mymenu
|
# MyMenu v1.0.0
|
||||||
|
|
||||||
|
|
||||||
|
## Descrição
|
||||||
|
Menu pessoal para jogadores em servidores
|
||||||
|
|
||||||
|
## Recursos do projeto
|
||||||
|
|
||||||
|
* [API](https://github.com/BrunoMine/oficios/archive/v1.0.0.zip)
|
||||||
|
|
||||||
|
## Requisitos
|
||||||
|
* Minetest 0.4.16 ou superior
|
||||||
|
* Mod default
|
||||||
|
* Mod sfinv
|
||||||
|
|
||||||
|
## Licença
|
||||||
|
Veja LICENSE.txt para informações detalhadas da licença LGPL 3.0
|
||||||
|
|
||||||
|
### Autores do código fonte
|
||||||
|
Originalmente por BrunoMine, Bruno Borges <borgesdossantosbruno@gmail.com> (LGPL 3.0)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
sfinv
|
||||||
|
default
|
|
@ -0,0 +1,91 @@
|
||||||
|
--[[
|
||||||
|
Mod MyMenu para Minetest
|
||||||
|
Copyright (C) 2017 BrunoMine (https://github.com/BrunoMine)
|
||||||
|
|
||||||
|
Recebeste uma cópia da GNU Lesser General
|
||||||
|
Public License junto com esse software,
|
||||||
|
se não, veja em <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Mudar idioma
|
||||||
|
]]
|
||||||
|
|
||||||
|
-- Algoritimo de tradução
|
||||||
|
local S, NS, SS, SNS = dofile(minetest.get_modpath("mymenu").."/lib/intllib.lua")
|
||||||
|
|
||||||
|
-- Algoritimo para pegar idioma com "mylang"
|
||||||
|
local getlang, setlang = dofile(minetest.get_modpath(minetest.get_current_modname()).."/lib/mylang.lua")
|
||||||
|
|
||||||
|
-- Tabela de idiomas selecionaveis
|
||||||
|
local tb_idiomas = {
|
||||||
|
["English"] = "en",
|
||||||
|
["Portugues"] = "pt",
|
||||||
|
["Espanol"] = "es",
|
||||||
|
}
|
||||||
|
-- Tabela de codigos com o numero
|
||||||
|
tb_idiomas_code = {}
|
||||||
|
do
|
||||||
|
local i = 1
|
||||||
|
for name,code in pairs(tb_idiomas) do
|
||||||
|
tb_idiomas_code[code] = i
|
||||||
|
i = i + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
-- String de idiomas em sequencia
|
||||||
|
local st_idiomas = ""
|
||||||
|
for name,code in pairs(tb_idiomas) do
|
||||||
|
if st_idiomas ~= "" then st_idiomas = st_idiomas .. "," end
|
||||||
|
st_idiomas = st_idiomas .. name
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Acessar menu de seleção de idiomas
|
||||||
|
local acessar_menu_idiomas = function(player)
|
||||||
|
local name = player:get_player_name()
|
||||||
|
local lang = getlang(name)
|
||||||
|
|
||||||
|
-- Idioma selecionado
|
||||||
|
local idioma_sel = "1"
|
||||||
|
if lang and tb_idiomas_code[lang] then
|
||||||
|
idioma_sel = tonumber(tb_idiomas_code[lang])
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local formspec = "size[5,5]"
|
||||||
|
..default.gui_bg
|
||||||
|
..default.gui_bg_img
|
||||||
|
.."label[0,0;"..SS(lang, "Escolha seu idioma").."]"
|
||||||
|
.."dropdown[0.125,1;5,5;idioma;"..st_idiomas..";"..(idioma_sel).."]"
|
||||||
|
.."button_exit[0,4.3;3,1;voltar;"..SS(lang, "Voltar").."]"
|
||||||
|
|
||||||
|
minetest.show_formspec(name, "mymenu:idiomas", formspec)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Receptor de botoes do menu de idiomas
|
||||||
|
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||||
|
if formname == "mymenu:idiomas" then
|
||||||
|
if not fields.quit and fields.idioma ~= "" and tb_idiomas[fields.idioma] then
|
||||||
|
setlang(player:get_player_name(), tb_idiomas[fields.idioma])
|
||||||
|
sfinv.set_player_inventory_formspec(player) -- Atualiza o inventario
|
||||||
|
acessar_menu_idiomas(player)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-- Registrar metodo de tradução instantanea
|
||||||
|
mymenu.register_tr(SS)
|
||||||
|
|
||||||
|
-- Registrar botao
|
||||||
|
mymenu.register_button("mymenu:abrir_menu", "Idioma")
|
||||||
|
|
||||||
|
-- Receber botao do inventario
|
||||||
|
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||||
|
if fields["mymenu:abrir_menu"] then
|
||||||
|
acessar_menu_idiomas(player)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
-- Traduções em separado
|
||||||
|
S("Idioma")
|
|
@ -0,0 +1,104 @@
|
||||||
|
--[[
|
||||||
|
Mod MyMenu para Minetest
|
||||||
|
Copyright (C) 2017 BrunoMine (https://github.com/BrunoMine)
|
||||||
|
|
||||||
|
Recebeste uma cópia da GNU Lesser General
|
||||||
|
Public License junto com esse software,
|
||||||
|
se não, veja em <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Menu pessoal
|
||||||
|
]]
|
||||||
|
|
||||||
|
local modpath = minetest.get_modpath("mymenu")
|
||||||
|
|
||||||
|
-- Algoritimo de tradução
|
||||||
|
local S, NS, SS, SNS = dofile(modpath.."/lib/intllib.lua")
|
||||||
|
|
||||||
|
-- Algoritimo para pegar idioma com "mylang"
|
||||||
|
local getlang = dofile(minetest.get_modpath(minetest.get_current_modname()).."/lib/mylang.lua")
|
||||||
|
|
||||||
|
-- Tabela global
|
||||||
|
mymenu = {}
|
||||||
|
|
||||||
|
-- Metodos de tradução registrados
|
||||||
|
local tr = {}
|
||||||
|
|
||||||
|
-- Registrar metodo de tradução
|
||||||
|
mymenu.register_tr = function(func)
|
||||||
|
|
||||||
|
if not func then
|
||||||
|
minetest.log("error", "[MyMenu] Metodo de tradução nulo (em mymenu.register_tr)")
|
||||||
|
return false
|
||||||
|
elseif type(func) ~= "function" then
|
||||||
|
minetest.log("error", "[MyMenu] Metodo de tradução invalido ("..type(func).."?) (em mymenu.register_tr)")
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
tr[minetest.get_current_modname()] = func
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Registrar botao
|
||||||
|
local buttons = {}
|
||||||
|
mymenu.register_button = function(field, label)
|
||||||
|
buttons[minetest.get_current_modname()] = {
|
||||||
|
field = field,
|
||||||
|
label = label,
|
||||||
|
}
|
||||||
|
|
||||||
|
if not tr[minetest.get_current_modname()] then
|
||||||
|
tr[minetest.get_current_modname()] = function(lang, string)
|
||||||
|
return string
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Pegar formspec com botoes
|
||||||
|
local get_formbuttons = function(player)
|
||||||
|
local f = "" -- formspec
|
||||||
|
local lang = getlang(player:get_player_name())
|
||||||
|
do
|
||||||
|
local c = 0 -- botoes contados
|
||||||
|
for mod,data in pairs(buttons) do
|
||||||
|
local fl = data.field..";"..tr[mod](lang, data.label)
|
||||||
|
if c == 0 then f = f .. "button[0,0;4,1;"..fl.."]"
|
||||||
|
elseif c == 1 then f = f .. "button[0,1;4,1;"..fl.."]"
|
||||||
|
elseif c == 2 then f = f .. "button[0,3;4,1;"..fl.."]"
|
||||||
|
elseif c == 3 then f = f .. "button[0,4;4,1;"..fl.."]"
|
||||||
|
elseif c == 4 then f = f .. "button[4,0;4,1;"..fl.."]"
|
||||||
|
elseif c == 5 then f = f .. "button[4,1;4,1;"..fl.."]"
|
||||||
|
elseif c == 6 then f = f .. "button[4,3;4,1;"..fl.."]"
|
||||||
|
elseif c == 7 then f = f .. "button[4,4;4,1;"..fl.."]"
|
||||||
|
end
|
||||||
|
c = c + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return f
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Registrar aba de configurações pessoais
|
||||||
|
sfinv.register_page("mymenu:menu", {
|
||||||
|
title = "Config",
|
||||||
|
get = function(self, player, context)
|
||||||
|
|
||||||
|
return sfinv.make_formspec(player, context,
|
||||||
|
get_formbuttons(player) .. [[
|
||||||
|
listring[current_player;main]
|
||||||
|
listring[current_player;craft]
|
||||||
|
image[0,4.75;1,1;gui_hb_bg.png]
|
||||||
|
image[1,4.75;1,1;gui_hb_bg.png]
|
||||||
|
image[2,4.75;1,1;gui_hb_bg.png]
|
||||||
|
image[3,4.75;1,1;gui_hb_bg.png]
|
||||||
|
image[4,4.75;1,1;gui_hb_bg.png]
|
||||||
|
image[5,4.75;1,1;gui_hb_bg.png]
|
||||||
|
image[6,4.75;1,1;gui_hb_bg.png]
|
||||||
|
image[7,4.75;1,1;gui_hb_bg.png]
|
||||||
|
]], true)
|
||||||
|
end
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Criar botao de idiomas
|
||||||
|
dofile(modpath.."/idioma.lua")
|
|
@ -0,0 +1,53 @@
|
||||||
|
|
||||||
|
-- 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, sgettext, sngettext
|
||||||
|
if minetest.get_modpath("intllib") then
|
||||||
|
if intllib.make_gettext_pair then
|
||||||
|
-- New method using gettext.
|
||||||
|
gettext, ngettext, sgettext, sngettext = 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
|
||||||
|
|
||||||
|
sgettext = sgettext or function(lang, msgid, ...)
|
||||||
|
return format(msgid, ...)
|
||||||
|
end
|
||||||
|
|
||||||
|
sngettext = sngettext or function(lang, msgid, msgid_plural, n, ...)
|
||||||
|
return format(n==1 and msgid or msgid_plural, ...)
|
||||||
|
end
|
||||||
|
|
||||||
|
return gettext, ngettext, sgettext, sngettext
|
|
@ -0,0 +1,329 @@
|
||||||
|
--[[
|
||||||
|
Lib MyLang para Minetest
|
||||||
|
Memor v1.3 Copyright (C) 2017 BrunoMine (https://github.com/BrunoMine)
|
||||||
|
|
||||||
|
Recebeste uma cópia da GNU Lesser General
|
||||||
|
Public License junto com esse software,
|
||||||
|
se não, veja em <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Gerencia os idiomas dos jogadores no servidor
|
||||||
|
]]
|
||||||
|
|
||||||
|
-- Lib Memor incorporada
|
||||||
|
|
||||||
|
local modname = "mylang"
|
||||||
|
|
||||||
|
local modpath = minetest.get_modpath(modname)
|
||||||
|
|
||||||
|
-- Variavel global
|
||||||
|
local memor = {}
|
||||||
|
|
||||||
|
-- Rotinas de interação com arquivos
|
||||||
|
|
||||||
|
-- Diretorio do mundo
|
||||||
|
local wpath = minetest.get_worldpath()
|
||||||
|
|
||||||
|
-- Cria um diretório na pasta do mundo
|
||||||
|
function memor.mkdir(dir)
|
||||||
|
if not dir then
|
||||||
|
minetest.log("error", "[Memor] Nenhum diretorio especificado (em memor.mkdir)")
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
dir = wpath.."/"..dir
|
||||||
|
|
||||||
|
if minetest.mkdir then
|
||||||
|
minetest.mkdir(dir)
|
||||||
|
else
|
||||||
|
os.execute('mkdir "' .. dir .. '"')
|
||||||
|
end
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Criar um arquivo com os dados serializados (Salvar)
|
||||||
|
function memor.escrever(dir, arquivo, dados)
|
||||||
|
|
||||||
|
if dir == nil or arquivo == nil or dados == nil then
|
||||||
|
minetest.log("error", "[Memor] Faltou dados (em memor.escrever)")
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
local dados = minetest.serialize(dados)
|
||||||
|
if dados == "" then
|
||||||
|
minetest.log("error", "[Memor] Dado fornecido invalido (em memor.escrever)")
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
local saida = io.open(wpath .. "/" .. modname .. "/" .. dir .. "/" .. arquivo, "w")
|
||||||
|
if saida then
|
||||||
|
saida:write(dados)
|
||||||
|
io.close(saida)
|
||||||
|
return true
|
||||||
|
else
|
||||||
|
minetest.log("info", "[Memor] memor.escrever tentou escrever num diretorio inexistente")
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Ler dados de um arquivo de memória (Carregar)
|
||||||
|
function memor.ler(dir, arquivo)
|
||||||
|
|
||||||
|
if dir == nil or arquivo == nil then
|
||||||
|
minetest.log("error", "[Memor] Faltou dados (em memor.ler)")
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
local entrada = io.open(wpath .. "/" .. modname .. "/" .. dir .. "/" .. arquivo, "r")
|
||||||
|
if entrada then
|
||||||
|
local dados = entrada:read("*l")
|
||||||
|
if dados ~= "" or dados ~= nil then
|
||||||
|
dados = minetest.deserialize(dados)
|
||||||
|
end
|
||||||
|
io.close(entrada)
|
||||||
|
return dados
|
||||||
|
else
|
||||||
|
minetest.log("error", "[Memor] pasta e/ou arquivo inexiste(s) (em memor.ler)")
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Deletar um arquivo
|
||||||
|
function memor.deletar(dir, arquivo)
|
||||||
|
|
||||||
|
if not dir or not arquivo then
|
||||||
|
minetest.log("error", "[Memor] Faltou dados (em memor.deletar)")
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
os.remove(wpath .. "/" .. modname .. "/" .. dir .. "/" .. arquivo)
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Deletar um diretório
|
||||||
|
function memor.deletar_dir(dir)
|
||||||
|
|
||||||
|
if not dir then
|
||||||
|
minetest.log("error", "[Memor] Faltou dados (em memor.deletar_dir)")
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
local list = minetest.get_dir_list(wpath .. "/" .. modname .. "/" .. dir)
|
||||||
|
|
||||||
|
for n, arquivo in ipairs(list) do
|
||||||
|
os.remove(wpath .. "/" .. modname .. "/" .. dir .. "/" .. arquivo)
|
||||||
|
end
|
||||||
|
|
||||||
|
os.remove(wpath .. "/" .. modname .. "/" .. dir)
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Fim
|
||||||
|
|
||||||
|
-- Rotinas de consutas a arquivos
|
||||||
|
|
||||||
|
-- Verifica diretorios e corrige
|
||||||
|
verificar = function(subdir)
|
||||||
|
|
||||||
|
local dir = modname
|
||||||
|
|
||||||
|
-- Verifica e corrige diretorio
|
||||||
|
local list = minetest.get_dir_list(minetest.get_worldpath(), true)
|
||||||
|
local r = false
|
||||||
|
for n, ndir in ipairs(list) do
|
||||||
|
if ndir == dir then
|
||||||
|
r = true
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
-- Diretorio inexistente
|
||||||
|
if r == false then
|
||||||
|
memor.mkdir(dir)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Verifica e corrige subdiretorio
|
||||||
|
list = minetest.get_dir_list(minetest.get_worldpath().."/"..dir, true)
|
||||||
|
r = false
|
||||||
|
for n, ndir in ipairs(list) do
|
||||||
|
if ndir == subdir then
|
||||||
|
r = true
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
-- Subdiretorio inexistente
|
||||||
|
if r == false then
|
||||||
|
memor.mkdir(dir.."/"..subdir)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Inserir dados
|
||||||
|
memor.inserir = function(tb, index, valor)
|
||||||
|
|
||||||
|
-- Tenta inserir direto
|
||||||
|
if memor.escrever(tb, index, valor) == true then return true end
|
||||||
|
|
||||||
|
verificar(tb)
|
||||||
|
|
||||||
|
if memor.escrever(tb, index, valor) then
|
||||||
|
return true
|
||||||
|
else
|
||||||
|
minetest.log("error", "[Memor] Impossivel salvar dados (em memor.inserir)")
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Ler dados
|
||||||
|
memor.consultar = function(tb, index)
|
||||||
|
|
||||||
|
local r = memor.ler(tb, index)
|
||||||
|
if r == nil then
|
||||||
|
local mod = modname
|
||||||
|
minetest.log("error", "[Memor] Registro acessado inexistente ("..dump(mod).."/"..dump(tb).."/"..dump(index)..") (em memor.consultar)")
|
||||||
|
end
|
||||||
|
|
||||||
|
return r
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Verificar dados
|
||||||
|
memor.verificar = function(subdir, arquivo)
|
||||||
|
|
||||||
|
local dir = modname
|
||||||
|
|
||||||
|
list = minetest.get_dir_list(wpath .. "/" .. dir .. "/" .. subdir)
|
||||||
|
r = false
|
||||||
|
for n, arq in ipairs(list) do
|
||||||
|
if arq == arquivo then
|
||||||
|
r = true
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if r then
|
||||||
|
return true
|
||||||
|
else
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Listar
|
||||||
|
memor.listar = function(subdir)
|
||||||
|
|
||||||
|
local dir = modname
|
||||||
|
|
||||||
|
if subdir then
|
||||||
|
|
||||||
|
local list = minetest.get_dir_list(wpath .. "/" .. dir .. "/" .. subdir)
|
||||||
|
|
||||||
|
if list == nil then
|
||||||
|
minetest.log("error", "[Memor] Impossivel listar diretorio (em memor.listar)")
|
||||||
|
return false
|
||||||
|
else
|
||||||
|
return list
|
||||||
|
end
|
||||||
|
|
||||||
|
else
|
||||||
|
local list = minetest.get_dir_list(wpath .. "/" .. dir)
|
||||||
|
|
||||||
|
if list == nil then
|
||||||
|
minetest.log("error", "[Memor] Impossivel listar diretorio (em memor.listar)")
|
||||||
|
return false
|
||||||
|
else
|
||||||
|
return list
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Fim
|
||||||
|
|
||||||
|
-- Montagem de banco de dados
|
||||||
|
|
||||||
|
bd = {}
|
||||||
|
|
||||||
|
-- Inserir dados
|
||||||
|
bd.salvar = function(tb, index, valor)
|
||||||
|
return memor.inserir(tb, index, valor)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Consultar dados
|
||||||
|
bd.pegar = function(tb, index)
|
||||||
|
return memor.consultar(tb, index)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Verificar dados
|
||||||
|
bd.verif = function(tb, index)
|
||||||
|
return memor.verificar(tb, index)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Remover dados
|
||||||
|
bd.remover = function(tb, index)
|
||||||
|
return memor.deletar(tb, index)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Remover tabela
|
||||||
|
bd.drop_tb = function(tb)
|
||||||
|
return memor.deletar_dir(tb)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Listar dados
|
||||||
|
bd.listar = function(tb)
|
||||||
|
return memor.listar(tb)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Fim
|
||||||
|
local respostas = {
|
||||||
|
["en"] = "English language defined.",
|
||||||
|
["pt"] = "Idioma portugues definido.",
|
||||||
|
["de"] = "Deutsch Sprache gesetzt.",
|
||||||
|
["es"] = "Idioma espanol definido.",
|
||||||
|
}
|
||||||
|
local resposta = function(lang)
|
||||||
|
if not respostas[lang] then
|
||||||
|
return lang.." language code defined"
|
||||||
|
else
|
||||||
|
return respostas[lang]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local definir_idioma = function(name, lang)
|
||||||
|
if name and lang then
|
||||||
|
bd.salvar("langs", name, lang)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Comando para escolher
|
||||||
|
minetest.register_chatcommand("mylang", {
|
||||||
|
params = "lang",
|
||||||
|
description = "Define o idioma preferencial",
|
||||||
|
privs = {},
|
||||||
|
func = function(name, param)
|
||||||
|
if not param then
|
||||||
|
return false, "No language defined. Use '/mylang lang-code' or '/mylang list' for see some lang codes."
|
||||||
|
end
|
||||||
|
if param == "list" then
|
||||||
|
return true, "Languague = lang-code | English = en | Deutsch = de | Portugues = pt | Espanol = es | Choose a lang code"
|
||||||
|
end
|
||||||
|
local lang = string.lower(param)
|
||||||
|
|
||||||
|
-- Salvar escolha
|
||||||
|
definir_idioma(name, lang)
|
||||||
|
|
||||||
|
|
||||||
|
return true, resposta(lang)
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Pegar idioma salvo
|
||||||
|
local pegar_idioma = function(name)
|
||||||
|
if bd.verif("langs", name) ~= true then
|
||||||
|
return "en"
|
||||||
|
end
|
||||||
|
return bd.pegar("langs", name)
|
||||||
|
end
|
||||||
|
|
||||||
|
return pegar_idioma, definir_idioma
|
|
@ -0,0 +1,31 @@
|
||||||
|
# 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.
|
||||||
|
# FULL NAME <EMAIL@ADDRESS>, 2017.
|
||||||
|
#
|
||||||
|
msgid ""
|
||||||
|
msgstr ""
|
||||||
|
"Project-Id-Version: PACKAGE VERSION\n"
|
||||||
|
"Report-Msgid-Bugs-To: \n"
|
||||||
|
"POT-Creation-Date: 2017-08-11 14:38-0300\n"
|
||||||
|
"PO-Revision-Date: 2017-08-11 14:39-0300\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"
|
||||||
|
"X-Generator: Gtranslator 2.91.7\n"
|
||||||
|
|
||||||
|
#: idioma.lua
|
||||||
|
msgid "Escolha seu idioma"
|
||||||
|
msgstr "Choose your language"
|
||||||
|
|
||||||
|
#: idioma.lua
|
||||||
|
msgid "Voltar"
|
||||||
|
msgstr "Return"
|
||||||
|
|
||||||
|
#: idioma.lua
|
||||||
|
msgid "Idioma"
|
||||||
|
msgstr "Language"
|
|
@ -0,0 +1,27 @@
|
||||||
|
# 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.
|
||||||
|
# FULL NAME <EMAIL@ADDRESS>, 2017.
|
||||||
|
#
|
||||||
|
msgid ""
|
||||||
|
msgstr ""
|
||||||
|
"Project-Id-Version: PACKAGE VERSION\n"
|
||||||
|
"Report-Msgid-Bugs-To: \n"
|
||||||
|
"POT-Creation-Date: 2017-08-11 13:28-0300\n"
|
||||||
|
"PO-Revision-Date: 2017-08-11 13:30-0300\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"
|
||||||
|
"X-Generator: Gtranslator 2.91.7\n"
|
||||||
|
|
||||||
|
#: idioma.lua
|
||||||
|
msgid "Escolha seu idioma"
|
||||||
|
msgstr "Choose your language"
|
||||||
|
|
||||||
|
#: idioma.lua
|
||||||
|
msgid "Voltar"
|
||||||
|
msgstr "Return"
|
|
@ -0,0 +1,31 @@
|
||||||
|
# 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.
|
||||||
|
# FULL NAME <EMAIL@ADDRESS>, 2017.
|
||||||
|
#
|
||||||
|
msgid ""
|
||||||
|
msgstr ""
|
||||||
|
"Project-Id-Version: PACKAGE VERSION\n"
|
||||||
|
"Report-Msgid-Bugs-To: \n"
|
||||||
|
"POT-Creation-Date: 2017-08-11 14:38-0300\n"
|
||||||
|
"PO-Revision-Date: 2017-08-11 14:39-0300\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"
|
||||||
|
"X-Generator: Gtranslator 2.91.7\n"
|
||||||
|
|
||||||
|
#: idioma.lua
|
||||||
|
msgid "Escolha seu idioma"
|
||||||
|
msgstr "Elegir su idioma"
|
||||||
|
|
||||||
|
#: idioma.lua
|
||||||
|
msgid "Voltar"
|
||||||
|
msgstr "Volver"
|
||||||
|
|
||||||
|
#: idioma.lua
|
||||||
|
msgid "Idioma"
|
||||||
|
msgstr "Idioma"
|
|
@ -0,0 +1,27 @@
|
||||||
|
# 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.
|
||||||
|
# FULL NAME <EMAIL@ADDRESS>, 2017.
|
||||||
|
#
|
||||||
|
msgid ""
|
||||||
|
msgstr ""
|
||||||
|
"Project-Id-Version: PACKAGE VERSION\n"
|
||||||
|
"Report-Msgid-Bugs-To: \n"
|
||||||
|
"POT-Creation-Date: 2017-08-11 13:28-0300\n"
|
||||||
|
"PO-Revision-Date: 2017-08-11 13:29-0300\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"
|
||||||
|
"X-Generator: Gtranslator 2.91.7\n"
|
||||||
|
|
||||||
|
#: idioma.lua
|
||||||
|
msgid "Escolha seu idioma"
|
||||||
|
msgstr "Elegir su idioma"
|
||||||
|
|
||||||
|
#: idioma.lua
|
||||||
|
msgid "Voltar"
|
||||||
|
msgstr "Volver"
|
|
@ -0,0 +1,31 @@
|
||||||
|
# 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.
|
||||||
|
# FULL NAME <EMAIL@ADDRESS>, 2017.
|
||||||
|
#
|
||||||
|
msgid ""
|
||||||
|
msgstr ""
|
||||||
|
"Project-Id-Version: PACKAGE VERSION\n"
|
||||||
|
"Report-Msgid-Bugs-To: \n"
|
||||||
|
"POT-Creation-Date: 2017-08-11 14:38-0300\n"
|
||||||
|
"PO-Revision-Date: 2017-08-11 14:38-0300\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"
|
||||||
|
"X-Generator: Gtranslator 2.91.7\n"
|
||||||
|
|
||||||
|
#: idioma.lua
|
||||||
|
msgid "Escolha seu idioma"
|
||||||
|
msgstr "Escolha seu idioma"
|
||||||
|
|
||||||
|
#: idioma.lua
|
||||||
|
msgid "Voltar"
|
||||||
|
msgstr "Voltar"
|
||||||
|
|
||||||
|
#: idioma.lua
|
||||||
|
msgid "Idioma"
|
||||||
|
msgstr "Idioma"
|
|
@ -0,0 +1,27 @@
|
||||||
|
# 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.
|
||||||
|
# FULL NAME <EMAIL@ADDRESS>, 2017.
|
||||||
|
#
|
||||||
|
msgid ""
|
||||||
|
msgstr ""
|
||||||
|
"Project-Id-Version: PACKAGE VERSION\n"
|
||||||
|
"Report-Msgid-Bugs-To: \n"
|
||||||
|
"POT-Creation-Date: 2017-08-11 13:28-0300\n"
|
||||||
|
"PO-Revision-Date: 2017-08-11 13:29-0300\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"
|
||||||
|
"X-Generator: Gtranslator 2.91.7\n"
|
||||||
|
|
||||||
|
#: idioma.lua
|
||||||
|
msgid "Escolha seu idioma"
|
||||||
|
msgstr "Escolha seu idioma"
|
||||||
|
|
||||||
|
#: idioma.lua
|
||||||
|
msgid "Voltar"
|
||||||
|
msgstr "Voltar"
|
|
@ -0,0 +1,30 @@
|
||||||
|
# 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-08-11 14:38-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"
|
||||||
|
|
||||||
|
#: idioma.lua
|
||||||
|
msgid "Escolha seu idioma"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: idioma.lua
|
||||||
|
msgid "Voltar"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: idioma.lua
|
||||||
|
msgid "Idioma"
|
||||||
|
msgstr ""
|
|
@ -0,0 +1,29 @@
|
||||||
|
#! /bin/bash
|
||||||
|
|
||||||
|
me=$(basename "${BASH_SOURCE[0]}");
|
||||||
|
|
||||||
|
if [[ $# -lt 1 ]]; then
|
||||||
|
echo "Usage: $me FILE..." >&2;
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
|
||||||
|
mkdir -p locale;
|
||||||
|
echo "Generating template..." >&2;
|
||||||
|
xgettext --from-code=UTF-8 \
|
||||||
|
--keyword=S \
|
||||||
|
--keyword=SS:2 \
|
||||||
|
--keyword=NS:1,2 \
|
||||||
|
--keyword=SNS:2,3 \
|
||||||
|
--keyword=N_ \
|
||||||
|
--add-comments='Translators:' \
|
||||||
|
--add-location=file \
|
||||||
|
-o locale/template.pot \
|
||||||
|
"$@" \
|
||||||
|
|| exit;
|
||||||
|
|
||||||
|
find locale -name '*.po' -type f | while read -r file; do
|
||||||
|
echo "Updating $file..." >&2;
|
||||||
|
msgmerge --update "$file" locale/template.pot;
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "DONE!" >&2;
|
Loading…
Reference in New Issue