From a4ed90174b9eb065bb38fc8bf6a3874cbf9ba264 Mon Sep 17 00:00:00 2001 From: BrunoMine Date: Tue, 10 Jul 2018 12:16:16 -0300 Subject: [PATCH] =?UTF-8?q?Adi=C3=A7=C3=A3o=20de=20sistema=20de=20tradu?= =?UTF-8?q?=C3=A7=C3=A3o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- depends.txt | 1 + init.lua | 6 +- lib/intllib.lua | 45 +++++++++++ locale/bau_coop.en.tr | 17 ++++ locale/bau_coop.pt.tr | 17 ++++ locale/en.mo | Bin 0 -> 1229 bytes locale/en.po | 79 +++++++++++++++++++ locale/en.po~ | 75 ++++++++++++++++++ locale/pt.mo | Bin 0 -> 1266 bytes locale/pt.po | 79 +++++++++++++++++++ locale/pt.po~ | 75 ++++++++++++++++++ locale/template.pot | 78 +++++++++++++++++++ nodes.lua | 38 ++++----- settingtypes.txt | 9 +++ tools/xgettext.bat | 33 ++++++++ tools/xgettext.sh | 27 +++++++ tradutor.lua | 177 ++++++++++++++++++++++++++++++++++++++++++ 17 files changed, 737 insertions(+), 19 deletions(-) create mode 100644 lib/intllib.lua create mode 100644 locale/bau_coop.en.tr create mode 100644 locale/bau_coop.pt.tr create mode 100644 locale/en.mo create mode 100644 locale/en.po create mode 100644 locale/en.po~ create mode 100644 locale/pt.mo create mode 100644 locale/pt.po create mode 100644 locale/pt.po~ create mode 100644 locale/template.pot create mode 100644 settingtypes.txt create mode 100644 tools/xgettext.bat create mode 100755 tools/xgettext.sh create mode 100644 tradutor.lua diff --git a/depends.txt b/depends.txt index 4ad96d5..9207dab 100644 --- a/depends.txt +++ b/depends.txt @@ -1 +1,2 @@ default +intllib? diff --git a/init.lua b/init.lua index 085d23c..251e4ee 100644 --- a/init.lua +++ b/init.lua @@ -1,6 +1,6 @@ --[[ Mod Bau_Coop para Minetest - Copyright (C) 2017 BrunoMine (https://github.com/BrunoMine) + Copyright (C) 2018 BrunoMine (https://github.com/BrunoMine) Recebeste uma cópia da GNU Lesser General Public License junto com esse software, @@ -12,6 +12,9 @@ -- Tabela global bau_coop = {} +-- Limite de acessos em um bau compartilhado +bau_coop.lim_acess = tonumber(minetest.setting_get("bau_coop_limite_acessos") or 10) + -- Notificador de Inicializador local notificar = function(msg) if minetest.setting_get("log_mods") then @@ -24,5 +27,6 @@ local modpath = minetest.get_modpath("bau_coop") -- Carregar scripts notificar("Carregando...") +dofile(modpath.."/tradutor.lua") dofile(modpath.."/nodes.lua") notificar("[OK]!") diff --git a/lib/intllib.lua b/lib/intllib.lua new file mode 100644 index 0000000..6669d72 --- /dev/null +++ b/lib/intllib.lua @@ -0,0 +1,45 @@ + +-- Fallback functions for when `intllib` is not installed. +-- Code released under Unlicense . + +-- 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 diff --git a/locale/bau_coop.en.tr b/locale/bau_coop.en.tr new file mode 100644 index 0000000..5d5ddd7 --- /dev/null +++ b/locale/bau_coop.en.tr @@ -0,0 +1,17 @@ +### Arquivo gerado por bau_coop apartir de en.po +# textdomain: bau_coop +Shared Chest=Shared Chest +Limit of @1 players=Limit of @1 players +Add new player=Add new player +Return=Return +Player already registered=Player already registered +@1 now has access=@1 now has access +No specified name=No specified name +@1 lost access=@1 lost access +Add Access=Add Access +Players with access=Players with access +Access Denied=Access Denied +Remove Access=Remove Access +Shared Chest (@1)=Shared Chest (@1) +You can not remove yourself=You can not remove yourself +Only one remaining owner=Only one remaining owner diff --git a/locale/bau_coop.pt.tr b/locale/bau_coop.pt.tr new file mode 100644 index 0000000..975c915 --- /dev/null +++ b/locale/bau_coop.pt.tr @@ -0,0 +1,17 @@ +### Arquivo gerado por bau_coop apartir de pt.po +# textdomain: bau_coop +Shared Chest=Bau Compartilhado +Limit of @1 players=Limite de @1 jogadores +Add new player=Adicionar novo jogador +Return=Voltar +Player already registered=Jogador ja registrado +@1 now has access=@1 agora tem acesso +No specified name=Nenhum nome especificado +@1 lost access=@1 perdeu o acesso +Add Access=Adicionar Acesso +Players with access=Jogadores com acesso +Access Denied=Acesso Negado +Remove Access=Remover Acesso +Shared Chest (@1)=Bau Compartilhado (@1) +You can not remove yourself=Nao pode remover a si mesmo +Only one remaining owner=Apenas um dono restante diff --git a/locale/en.mo b/locale/en.mo new file mode 100644 index 0000000000000000000000000000000000000000..ec329ab8b6e312a3c30594a8cca81a10b6de8a07 GIT binary patch literal 1229 zcmZXSzi$;s5XYB<{NN=J!jF(B6ay75&Uw#~zn!Xt>?!P$ z?oZ%>^%y)4&cSowkKk$W7f@qffS-ZCgBtf2_$l~LubX#_xrp;6@B)~D>c0+t2|ffr z2OIDV_!Ia(_zb*?JAMWAzCYjX-oFGj|KH#M{I}Onob2v73w{iJ0o1tb;1}Sxp!V^o z=K-kspMdK39MpS%12z92Akv#pV7gR01%qrpfa%iyk1vh?5cUxaWoheejX>L*)}`w` zecT+8ol3BjxFVZ#jG|i2q2Pw(NLp*(&^AwPA!e;`xf5>#b^0;E%Yo3os9P{=HG3PW zsi+Vy6gVd96PtD0(1ujC4at==z40xDuH76hn0wttv~LkSbuk5X?p2PI%YQ|0y2>S{ zf(hmK1#mRmR;U)Jfh#%SK$fDTien{aoBa&6d8wE<)||UNmurHZ-nZ}Wft1MxGYPWK zdCKk<*#iy{A7D&_9j+y$Y%5M(k*zn=nC%MW$^C4H51cw>w`}4uEe%J@+3-d-8q#QK zjLq=t;c&2NW6E}e^|7=`0wOo9pEh>N*)H4a*m+Fs2U~ZyZof%BS{x2G1RvDnj(LqF zi65u0>e4#DLix;w$Z7Ta-8Z`gC_ikJu&F45BB zaPj(JQZ~Vs*&PX09FwoxV_aQYp>Df+&C``t8ZE30baK2L(hNV{<~lN}loHd?ajjM9 z7JJ79#-_jowSKzwe26>koP)XV%Q=Z}e;c|%og{~-&wPijxS)+0X6b*2ZeS*DIN36= zE$02uFd|I%Ceooxv!iO-nIYNJk?9gg^H3Vftw$fJpBb7, YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: \n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-07-10 12:07-0300\n" +"PO-Revision-Date: 2018-07-10 12:07-0300\n" +"Last-Translator: \n" +"Language-Team: \n" +"Language: en\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" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: nodes.lua +msgid "Acesso Negado" +msgstr "Access Denied" + +#: nodes.lua +msgid "Bau Compartilhado" +msgstr "Shared Chest" + +#: nodes.lua +msgid "Voltar" +msgstr "Return" + +#: nodes.lua +msgid "Adicionar novo jogador" +msgstr "Add new player" + +#: nodes.lua +msgid "Adicionar Acesso" +msgstr "Add Access" + +#: nodes.lua +msgid "Jogadores com acesso" +msgstr "Players with access" + +#: nodes.lua +msgid "Remover Acesso" +msgstr "Remove Access" + +#: nodes.lua +msgid "Nenhum nome especificado" +msgstr "No specified name" + +#: nodes.lua +msgid "Limite de @1 jogadores" +msgstr "Limit of @1 players" + +#: nodes.lua +msgid "Jogador ja registrado" +msgstr "Player already registered" + +#: nodes.lua +msgid "@1 agora tem acesso" +msgstr "@1 now has access" + +#: nodes.lua +msgid "Nao pode remover a si mesmo" +msgstr "You can not remove yourself" + +#: nodes.lua +msgid "Apenas um dono restante" +msgstr "Only one remaining owner" + +#: nodes.lua +msgid "@1 perdeu o acesso" +msgstr "@1 lost access" + +#: nodes.lua +msgid "Bau Compartilhado (@1)" +msgstr "Shared Chest (@1)" diff --git a/locale/en.po~ b/locale/en.po~ new file mode 100644 index 0000000..04ad57d --- /dev/null +++ b/locale/en.po~ @@ -0,0 +1,75 @@ +# 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 , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: \n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-07-10 11:55-0300\n" +"PO-Revision-Date: 2018-07-10 12:02-0300\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: \n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"Language: en\n" + +#: nodes.lua +msgid "Acesso Negado" +msgstr "Access Denied" + +#: nodes.lua +msgid "Bau Compartilhado" +msgstr "Shared Chest" + +#: nodes.lua +msgid "Adicionar novo jogador" +msgstr "Add new player" + +#: nodes.lua +msgid "Adicionar Acesso" +msgstr "Add Access" + +#: nodes.lua +msgid "Jogadores com acesso" +msgstr "Players with access" + +#: nodes.lua +msgid "Remover Acesso" +msgstr "Remove Access" + +#: nodes.lua +msgid "Nenhum nome especificado" +msgstr "No specified name" + +#: nodes.lua +msgid "Limite de @1 jogadores" +msgstr "Limit of @1 players" + +#: nodes.lua +msgid "Jogador ja registrado" +msgstr "Player already registered" + +#: nodes.lua +msgid "@1 agora tem acesso" +msgstr "@1 now has access" + +#: nodes.lua +msgid "Nao pode remover a si mesmo" +msgstr "You can not remove yourself" + +#: nodes.lua +msgid "Apenas um dono restante" +msgstr "Only one remaining owner" + +#: nodes.lua +msgid "@1 perdeu o acesso" +msgstr "@1 lost access" + +#: nodes.lua +msgid "Bau Compartilhado (@1)" +msgstr "Shared Chest (@1)" diff --git a/locale/pt.mo b/locale/pt.mo new file mode 100644 index 0000000000000000000000000000000000000000..2347153c9f69d2da508da3fb0ccf5482e7127b97 GIT binary patch literal 1266 zcmeH_%W4!s6oyNUx7K)xmk7Ezii>1Xab^S!69;lJkw`LzFa}+g-6x$6(^XAXO-S$= z6gTb^TnO%b1s5)S12>888Go482r{Gsr8*SIALW zAHV~#4W0vcz!C5nI1Ii4<;;8VBKQH6bDzPp;O;j{U~@I)S%SQf|tR^;3cpJ zo&ukPN5I$MHS~B3ivOoWeg7|@`0s+^{{xhM!$W=l>!A4G0Yz_v;?JP?KON{VK=FSE zivLGY{J(VCfwZ5kZTix9mO4^$46y5B=D6=e~bGA4{a z7=VLn8%LFc>bZ1V?8#6lsN_&O)n>ba*{my>I8>Y#>qROCtApCX*R8p3G+wQEx5;VL ziYBn%QMzG#;MjWDScnfEy`HzJ%LHfk5484Z_~furk`U0Mq>Z~ literal 0 HcmV?d00001 diff --git a/locale/pt.po b/locale/pt.po new file mode 100644 index 0000000..01e0461 --- /dev/null +++ b/locale/pt.po @@ -0,0 +1,79 @@ +# 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 , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: \n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-07-10 12:07-0300\n" +"PO-Revision-Date: 2018-07-10 12:07-0300\n" +"Last-Translator: \n" +"Language-Team: \n" +"Language: pt\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" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: nodes.lua +msgid "Acesso Negado" +msgstr "Acesso Negado" + +#: nodes.lua +msgid "Bau Compartilhado" +msgstr "Bau Compartilhado" + +#: nodes.lua +msgid "Voltar" +msgstr "Voltar" + +#: nodes.lua +msgid "Adicionar novo jogador" +msgstr "Adicionar novo jogador" + +#: nodes.lua +msgid "Adicionar Acesso" +msgstr "Adicionar Acesso" + +#: nodes.lua +msgid "Jogadores com acesso" +msgstr "Jogadores com acesso" + +#: nodes.lua +msgid "Remover Acesso" +msgstr "Remover Acesso" + +#: nodes.lua +msgid "Nenhum nome especificado" +msgstr "Nenhum nome especificado" + +#: nodes.lua +msgid "Limite de @1 jogadores" +msgstr "Limite de @1 jogadores" + +#: nodes.lua +msgid "Jogador ja registrado" +msgstr "Jogador ja registrado" + +#: nodes.lua +msgid "@1 agora tem acesso" +msgstr "@1 agora tem acesso" + +#: nodes.lua +msgid "Nao pode remover a si mesmo" +msgstr "Nao pode remover a si mesmo" + +#: nodes.lua +msgid "Apenas um dono restante" +msgstr "Apenas um dono restante" + +#: nodes.lua +msgid "@1 perdeu o acesso" +msgstr "@1 perdeu o acesso" + +#: nodes.lua +msgid "Bau Compartilhado (@1)" +msgstr "Bau Compartilhado (@1)" diff --git a/locale/pt.po~ b/locale/pt.po~ new file mode 100644 index 0000000..5826bbe --- /dev/null +++ b/locale/pt.po~ @@ -0,0 +1,75 @@ +# 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 , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: \n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-07-10 11:55-0300\n" +"PO-Revision-Date: 2018-07-10 11:56-0300\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: \n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"Language: pt\n" + +#: nodes.lua +msgid "Acesso Negado" +msgstr "Acesso Negado" + +#: nodes.lua +msgid "Bau Compartilhado" +msgstr "Bau Compartilhado" + +#: nodes.lua +msgid "Adicionar novo jogador" +msgstr "Adicionar novo jogador" + +#: nodes.lua +msgid "Adicionar Acesso" +msgstr "Adicionar Acesso" + +#: nodes.lua +msgid "Jogadores com acesso" +msgstr "Jogadores com acesso" + +#: nodes.lua +msgid "Remover Acesso" +msgstr "Remover Acesso" + +#: nodes.lua +msgid "Nenhum nome especificado" +msgstr "Nenhum nome especificado" + +#: nodes.lua +msgid "Limite de @1 jogadores" +msgstr "Limite de @1 jogadores" + +#: nodes.lua +msgid "Jogador ja registrado" +msgstr "Jogador ja registrado" + +#: nodes.lua +msgid "@1 agora tem acesso" +msgstr "@1 agora tem acesso" + +#: nodes.lua +msgid "Nao pode remover a si mesmo" +msgstr "Nao pode remover a si mesmo" + +#: nodes.lua +msgid "Apenas um dono restante" +msgstr "Apenas um dono restante" + +#: nodes.lua +msgid "@1 perdeu o acesso" +msgstr "@1 perdeu o acesso" + +#: nodes.lua +msgid "Bau Compartilhado (@1)" +msgstr "Bau Compartilhado (@1)" diff --git a/locale/template.pot b/locale/template.pot new file mode 100644 index 0000000..6d3199d --- /dev/null +++ b/locale/template.pot @@ -0,0 +1,78 @@ +# 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 , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-07-10 12:07-0300\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#: nodes.lua +msgid "Acesso Negado" +msgstr "" + +#: nodes.lua +msgid "Bau Compartilhado" +msgstr "" + +#: nodes.lua +msgid "Voltar" +msgstr "" + +#: nodes.lua +msgid "Adicionar novo jogador" +msgstr "" + +#: nodes.lua +msgid "Adicionar Acesso" +msgstr "" + +#: nodes.lua +msgid "Jogadores com acesso" +msgstr "" + +#: nodes.lua +msgid "Remover Acesso" +msgstr "" + +#: nodes.lua +msgid "Nenhum nome especificado" +msgstr "" + +#: nodes.lua +msgid "Limite de @1 jogadores" +msgstr "" + +#: nodes.lua +msgid "Jogador ja registrado" +msgstr "" + +#: nodes.lua +msgid "@1 agora tem acesso" +msgstr "" + +#: nodes.lua +msgid "Nao pode remover a si mesmo" +msgstr "" + +#: nodes.lua +msgid "Apenas um dono restante" +msgstr "" + +#: nodes.lua +msgid "@1 perdeu o acesso" +msgstr "" + +#: nodes.lua +msgid "Bau Compartilhado (@1)" +msgstr "" diff --git a/nodes.lua b/nodes.lua index 5e610d1..376356b 100644 --- a/nodes.lua +++ b/nodes.lua @@ -9,6 +9,8 @@ Nodes ]] +-- Tradutor +local S = bau_coop.S -- Variavel de acesso local acessos = {} @@ -23,7 +25,7 @@ local formspec_acesso_negado = "size[7,2]" .. default.gui_bg .. default.gui_bg_img .. "image[0,0;2,2;bau_coop_acesso.png]" - .. "label[2,0.75;"..core.colorize("#FF0000", "Acesso Negado").."]" + .. "label[2,0.75;"..core.colorize("#FF0000", S("Acesso Negado")).."]" local function pegar_formspec_bau_compartilhado(pos) @@ -39,7 +41,7 @@ local function pegar_formspec_bau_compartilhado(pos) "listring[nodemeta:" .. spos .. ";main]" .. "listring[current_player;main]" .. default.get_hotbar_bg(0,5.85) .. - "label[0,0;Bau Compartilhado]" .. + "label[0,0;"..S("Bau Compartilhado").."]" .. "image_button[7,0;1,1;bau_coop_acesso.png;controle_acesso;]" return formspec end @@ -58,15 +60,15 @@ local function pegar_formspec_painel_acesso(name, meta, msg, erro) .. default.gui_bg .. default.gui_bg_img .. "image[0,0;2,2;bau_coop_acesso.png]" - .. "label[2,0;Bau Compartilhado]" - .. "button[6,0;2,1;voltar;Voltar]" + .. "label[2,0;"..S("Bau Compartilhado").."]" + .. "button[6,0;2,1;voltar;"..S("Voltar").."]" -- Adicionar acesso - .. "field[0.3,2.8;4.8,1;novo_acesso;Adicionar novo jogador;]" - .. "button[5,2.49;3,1;adicionar;Adicionar Acesso]" + .. "field[0.3,2.8;4.8,1;novo_acesso;"..S("Adicionar novo jogador")..";]" + .. "button[5,2.49;3,1;adicionar;"..S("Adicionar Acesso").."]" -- Remover acesso - .. "label[0,3.7;Jogadores com acesso]" + .. "label[0,3.7;"..S("Jogadores com acesso").."]" .. "dropdown[0,4.125;5,1;nome_acesso;"..lista..";]" - .. "button[5,4;3,1;remover;Remover Acesso]" + .. "button[5,4;3,1;remover;"..S("Remover Acesso").."]" if msg then if erro then @@ -166,16 +168,16 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) return minetest.show_formspec( player:get_player_name(), "bau_coop:bau_compartilhado", - pegar_formspec_painel_acesso(player:get_player_name(), meta, "Nenhum nome especificado", true) + pegar_formspec_painel_acesso(player:get_player_name(), meta, S("Nenhum nome especificado"), true) ) end -- Verificar se ja esta no limite de acessos - if table.maxn(donos) >= 10 then + if table.maxn(donos) >= bau_coop.lim_acess then return minetest.show_formspec( player:get_player_name(), "bau_coop:bau_compartilhado", - pegar_formspec_painel_acesso(player:get_player_name(), meta, "Limite de 10 jogadores", true) + pegar_formspec_painel_acesso(player:get_player_name(), meta, S("Limite de @1 jogadores", bau_coop.lim_acess), true) ) end @@ -185,7 +187,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) return minetest.show_formspec( player:get_player_name(), "bau_coop:bau_compartilhado", - pegar_formspec_painel_acesso(player:get_player_name(), meta, "Jogador ja registrado", true) + pegar_formspec_painel_acesso(player:get_player_name(), meta, S("Jogador ja registrado"), true) ) end end @@ -200,7 +202,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) return minetest.show_formspec( player:get_player_name(), "bau_coop:bau_compartilhado", - pegar_formspec_painel_acesso(player:get_player_name(), meta, fields.novo_acesso.." agora tem acesso") + pegar_formspec_painel_acesso(player:get_player_name(), meta, S("@1 agora tem acesso", fields.novo_acesso)) ) -- Remover acesso de um jogador @@ -212,7 +214,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) return minetest.show_formspec( player:get_player_name(), "bau_coop:bau_compartilhado", - pegar_formspec_painel_acesso(player:get_player_name(), meta, "Nao pode remover a si mesmo", true) + pegar_formspec_painel_acesso(player:get_player_name(), meta, S("Nao pode remover a si mesmo"), true) ) end @@ -221,7 +223,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) return minetest.show_formspec( player:get_player_name(), "bau_coop:bau_compartilhado", - pegar_formspec_painel_acesso(player:get_player_name(), meta, "Apenas um dono restante", true) + pegar_formspec_painel_acesso(player:get_player_name(), meta, S("Apenas um dono restante"), true) ) end @@ -250,7 +252,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) return minetest.show_formspec( player:get_player_name(), "bau_coop:bau_compartilhado", - pegar_formspec_painel_acesso(player:get_player_name(), meta, fields.nome_acesso.." perdeu o acesso") + pegar_formspec_painel_acesso(player:get_player_name(), meta, S("@1 perdeu o acesso", fields.nome_acesso)) ) -- Voltar para a formspec normal do bau @@ -270,7 +272,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) end) minetest.register_node("bau_coop:bau_compartilhado", { - description = "Bau Compartilhado", + description = S("Bau Compartilhado"), tiles = { "default_chest_top.png", "default_chest_top.png", @@ -289,7 +291,7 @@ minetest.register_node("bau_coop:bau_compartilhado", { local meta = minetest.get_meta(pos) meta:set_string("dono", placer:get_player_name()) meta:set_string("permitidos", minetest.serialize({placer:get_player_name()})) - meta:set_string("infotext", "Bau Compartilhado ("..placer:get_player_name()..")") + meta:set_string("infotext", S("Bau Compartilhado (@1)", placer:get_player_name())) end, on_construct = function(pos) local meta = minetest.get_meta(pos) diff --git a/settingtypes.txt b/settingtypes.txt new file mode 100644 index 0000000..c0c17f6 --- /dev/null +++ b/settingtypes.txt @@ -0,0 +1,9 @@ +# Configurações aplicaveis para o menu gráfico + +#Limite de acessos de jogadores em um mesmo bau compartilhado +#Limit of players in the same shared chest +bau_coop_limite_acessos (Limite de acessos) int 10 0 + + + + diff --git a/tools/xgettext.bat b/tools/xgettext.bat new file mode 100644 index 0000000..18403db --- /dev/null +++ b/tools/xgettext.bat @@ -0,0 +1,33 @@ +@echo off +setlocal + +set me=%~n0 + +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 locale/template.pot %* +%xgettext% --from-code=UTF-8 -kS -kNS:1,2 -k_ -o locale/template.pot %* +if %ERRORLEVEL% neq 0 goto done + +cd locale + +for %%f in (*.po) do ( + echo Updating %%f... 1>&2 + %msgmerge% --update %%f template.pot +) + +echo DONE! 1>&2 + +:done diff --git a/tools/xgettext.sh b/tools/xgettext.sh new file mode 100755 index 0000000..1504f42 --- /dev/null +++ b/tools/xgettext.sh @@ -0,0 +1,27 @@ +#! /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=NS:1,2 \ + --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; diff --git a/tradutor.lua b/tradutor.lua new file mode 100644 index 0000000..12888e4 --- /dev/null +++ b/tradutor.lua @@ -0,0 +1,177 @@ +--[[ + Mod bau_coop para Minetest + Copyright (C) 2018 BrunoMine (https://github.com/BrunoMine) + + Recebeste uma cópia da GNU Lesser General + Public License junto com esse software, + se não, veja em . + + Sistema de tradução + ]] + +-- Modpath +local modpath = minetest.get_modpath("bau_coop") + +-- Tradução intllib +bau_coop.intllib = {} +bau_coop.intllib.S, bau_coop.intllib.NS = dofile(modpath.."/lib/intllib.lua") + +-- Configura tradutor opicional +bau_coop.S = bau_coop.intllib.S +bau_coop.NS = bau_coop.intllib.NS + +-- +-- Ajustes devido ao bug de tradutor ler apenas traduzir do ingles +-- + +-- Strings para repassar textos em ingles +local pt_to_en = {} + +-- Gera arquivos de tradução bau_coop.*.tr +do + local file_to_tb = function(file) + local msgid = nil + local msgstr = nil + local tb = {} + for line in io.lines(file) do + + -- Iniciando 'msgid' + if string.sub(line, 1, 5) == "msgid" then + + -- Escrever no catalogo a anterior + if msgid ~= nil and msgstr ~= nil then + if msgid ~= "" then + tb[msgid] = msgstr + end + msgid = nil + msgstr = nil + end + + if line == "msgid \"\"" then + msgid = "" + else + msgid = string.sub(line, 8, (string.len(line)-1)) + end + + -- Continuando 'msgid' + elseif string.sub(line, 1, 1) == "\"" and msgstr == nil and msgid ~= nil then + msgid = msgid .. string.sub(line, 2, (string.len(line)-1)) + + -- Iniciando 'msgstr' + elseif string.sub(line, 1, 6) == "msgstr" then + + if line == "msgstr \"\"" then + msgstr = "" + else + msgstr = string.sub(line, 9, (string.len(line)-1)) + end + + -- Continuando 'msgstr' + elseif string.sub(line, 1, 1) == "\"" and msgstr ~= nil then + msgstr = msgstr .. string.sub(line, 2, (string.len(line)-1)) + + end + + + end + + -- Escrever ultima + if msgid ~= nil and msgstr ~= nil then + if msgid ~= "" then + tb[msgid] = msgstr + end + msgid = nil + msgstr = nil + end + + return tb + end + + -- Pegar strings principais en-pt para realizar as trocas + pt_to_en = file_to_tb(modpath.."/locale/en.po") + + --minetest.log("error", "pt_to_en = "..dump(pt_to_en)) + + local list = minetest.get_dir_list(modpath.."/locale") + for _,file in ipairs(list) do + + if string.match(file, "~") == nil then + + -- Traduções ".po" + if string.match(file, ".pot") == nil and string.match(file, ".po") then + + local lang_code = string.gsub(file, ".po", "") + + local pt_to_lang = file_to_tb(modpath.."/locale/"..file) + + -- tabela desejada + local en_to_lang = {} + for pt,en in pairs(pt_to_en) do + en_to_lang[en] = pt_to_lang[pt] + end + + -- Novo arquivo + local new_file = "### Arquivo gerado por bau_coop apartir de "..file.."\n# textdomain: bau_coop\n" + for en,lang in pairs(en_to_lang) do + new_file = new_file .. en .. "=" .. lang .. "\n" + end + -- Escrever arquivo + local saida = io.open(modpath.."/locale/bau_coop."..lang_code..".tr", "w") + saida:write(new_file) + io.close(saida) + end + end + end +end + +-- Ajuste para repassar termos em ingles +local s +if minetest.get_translator ~= nil then + s = minetest.get_translator("bau_coop") +else + s = bau_coop.intllib.S +end + +bau_coop.s = function(...) + local args = { ... } + if pt_to_en[args[1]] ~= nil then + return s(pt_to_en[args[1]], unpack(args, 2)) + end + minetest.log("error", "[bau_coop] String "..dump(args[1]).." nao catalogada") + return s(...) +end + +-- Não troca string caso esteja trabalhando com intllib +if minetest.get_modpath("intllib") ~= nil + and minetest.get_translator == nil +then + bau_coop.s = s +end + +bau_coop.S = function(...) + local args = { ... } + if type(args[1]) == "table" then + local r = {} + for n,a in ipairs(args[1]) do + if n ~= 1 then -- Não traduz o primeiro + table.insert(r, bau_coop.S(a)) + else + table.insert(r, a) + end + end + + return bau_coop.s(unpack(r)) + + elseif type(args[1]) == "string" then + -- Não traduz caso faltem argumentos (devido strings ilustrativas) + return bau_coop.s(...) + + else + return args[1] + end +end + +-- Função que retorna a string inalterada para passar pela checagem +bau_coop.Sfake = function(s) return s end + +