From 71c9e8c5689e80c80fa4804b75528ef1d3b0b941 Mon Sep 17 00:00:00 2001 From: BrunoMine Date: Wed, 27 Jun 2018 17:19:34 -0300 Subject: [PATCH] =?UTF-8?q?Adi=C3=A7=C3=A3o=20de=20tradu=C3=A7=C3=B5es?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- chat.lua | 15 +-- init.lua | 1 + lib/intllib.lua | 45 ++++++++ locale/Arquivos para traduzir.txt | 1 + locale/en.mo | Bin 0 -> 1752 bytes locale/en.po | 139 ++++++++++++++++++++++++ locale/multichat.en.tr | 32 ++++++ locale/multichat.pt.tr | 32 ++++++ locale/pt.mo | Bin 0 -> 1816 bytes locale/pt.po | 139 ++++++++++++++++++++++++ locale/template.pot | 138 ++++++++++++++++++++++++ menu.lua | 82 +++++++------- tools/xgettext.bat | 33 ++++++ tools/xgettext.sh | 27 +++++ tradutor.lua | 173 ++++++++++++++++++++++++++++++ 15 files changed, 811 insertions(+), 46 deletions(-) create mode 100644 lib/intllib.lua create mode 100644 locale/Arquivos para traduzir.txt create mode 100644 locale/en.mo create mode 100644 locale/en.po create mode 100644 locale/multichat.en.tr create mode 100644 locale/multichat.pt.tr create mode 100644 locale/pt.mo create mode 100644 locale/pt.po create mode 100644 locale/template.pot create mode 100644 tools/xgettext.bat create mode 100755 tools/xgettext.sh create mode 100644 tradutor.lua diff --git a/chat.lua b/chat.lua index 4f49bb9..6cf8b31 100644 --- a/chat.lua +++ b/chat.lua @@ -10,16 +10,19 @@ ]] +local S = multichat.S -minetest.register_privilege("chat_admin", "Usar char como administrador") -minetest.register_privilege("chat_staff", "Usar char como moderador") +minetest.register_privilege("chat_admin", S("Usar chat como administrador")) +minetest.register_privilege("chat_staff", S("Usar chat como moderador")) -- Grupos privados de cada jogador multichat.grupos = {} -- Pegar prefixos -multichat.admin_prefix = minetest.setting_get("multichat_admin_prefix") or "ADMIN" -multichat.staff_prefix = minetest.setting_get("multichat_staff_prefix") or "MODERADOR" +S = multichat.Sfake +multichat.admin_prefix = minetest.setting_get("multichat_admin_prefix") or S("ADMIN") +multichat.staff_prefix = minetest.setting_get("multichat_staff_prefix") or S("MODERADOR") +S = multichat.S local tocar_som = function(player) minetest.sound_play("multichat_aviso", {object = player,gain = 0.5,max_hear_distance = 1}) end local tocar_chamada = function(player) minetest.sound_play("multichat_chamada", {object = player,gain = 0.5,max_hear_distance = 1}) end @@ -43,8 +46,8 @@ local som_avisar = multichat.som_avisar -- Pegar prefixo multichat.prefixo = function(name) - if minetest.check_player_privs(name, {chat_admin=true}) then return "["..multichat.admin_prefix.."]" end - if minetest.check_player_privs(name, {chat_staff=true}) then return "["..multichat.staff_prefix.."]" end + if minetest.check_player_privs(name, {chat_admin=true}) then return "["..S(multichat.admin_prefix).."]" end + if minetest.check_player_privs(name, {chat_staff=true}) then return "["..S(multichat.staff_prefix).."]" end return "" end diff --git a/init.lua b/init.lua index c2dd4b5..7d440ab 100644 --- a/init.lua +++ b/init.lua @@ -37,6 +37,7 @@ local modpath = minetest.get_modpath("multichat") -- Carregar scripts notificar("Carregando...") +dofile(modpath.."/tradutor.lua") dofile(modpath.."/online.lua") dofile(modpath.."/chat.lua") dofile(modpath.."/menu.lua") 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/Arquivos para traduzir.txt b/locale/Arquivos para traduzir.txt new file mode 100644 index 0000000..31be9ad --- /dev/null +++ b/locale/Arquivos para traduzir.txt @@ -0,0 +1 @@ +me.lua menu.lua msg.lua online.lua chat.lua comandos.lua diff --git a/locale/en.mo b/locale/en.mo new file mode 100644 index 0000000000000000000000000000000000000000..42c97e65249650a4bfb92b970500725d7ac3bb27 GIT binary patch literal 1752 zcmZ{jO^g&p6vs;hKL!xR)dd7CNlYZB)|tWJI-3a&J2UGh4m+70h$hCQX1aE^pu4J5 zUA@aDax(Ei!VN-5yc(_$4@Nzy2QS8>-Zt^#(F+M4y!e0JHM=6AGF89&>i7Py-ka^i zdv7wd*U*on&pg4{De%A^3}|=3ec(N?0)7KN3;r0^zl8Pg;0*Tv0QZ9r!ug&j%likx zz1W`xPlCt6SHZJ^pMvD)DoFM}54;W@#QGNa68IH(4E!E^8vHGAJMd4C{QL#t$L?dG zxc&x@fHOFJ3KZZo;5#72)eQUqJc&101xe2a2Ga8xNcO%6>uVscup1!hyA6`PJArpW z()TThANv8r%izx->DdNf0sjHHAHP-uEg-`PuQ?8R~KRdgm)Giz+IymUx>~J#D9t376D5X9 zCit$m-0SRGugz5}NU6t5h~ZWWD_&jkZ>O=;W`V+VnexpG!>*X$z2~IK)|3++Gq#a7 zlLnt3X$)Vw<^+}*XOEpXP_a2dHO6aPb>X6cQO`T>yoU&O|>krO?=Hg6{pS9BDoK3`*qYZl@4l}GXLmdk-ze6iENaWN#2L8ZkP48c%cj| zvJN}NntU6jBJzF7YQtqIp{zpu8Oy?8Wf8K@741=jxrtC{ijypo!`JQRf9ep=|LAe% W<=PtT_}m!=N2N+kf*#rn&i(~gnUKi< literal 0 HcmV?d00001 diff --git a/locale/en.po b/locale/en.po new file mode 100644 index 0000000..c390343 --- /dev/null +++ b/locale/en.po @@ -0,0 +1,139 @@ +# 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-06-27 11:41-0300\n" +"PO-Revision-Date: 2018-06-27 12:19-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" + +#: menu.lua +msgid "Atualmente" +msgstr "Currently" + +#: menu.lua +msgid "em Publico" +msgstr "in Public" + +#: menu.lua +msgid "Desativado" +msgstr "Disabled" + +#: menu.lua +msgid "em Privado" +msgstr "in Private" + +#: menu.lua +msgid "em Grupo" +msgstr "in Group" + +#: menu.lua +msgid "Erro" +msgstr "Error" + +#: menu.lua +msgid "Meu Bate-Papo" +msgstr "My Chat" + +#: menu.lua +msgid "Som" +msgstr "Sound" + +#: menu.lua +msgid "Sair" +msgstr "Exit" + +#: menu.lua +msgid "Desativar" +msgstr "Disable" + +#: menu.lua +msgid "Publico" +msgstr "Public" + +#: menu.lua +msgid "Privado" +msgstr "Private" + +#: menu.lua +msgid "Grupo" +msgstr "Group" + +#: menu.lua +msgid "Meu Bate-Papo Privado" +msgstr "My Private Chat" + +#: menu.lua +msgid "Voltar" +msgstr "Return" + +#: menu.lua +msgid "Ignorados" +msgstr "Ignored" + +#: menu.lua +msgid "Adicionar" +msgstr "Add" + +#: menu.lua +msgid "Remover" +msgstr "Remove" + +#: menu.lua +msgid "Conversando" +msgstr "Speaking" + +#: menu.lua +msgid "Bate-papo desativado" +msgstr "Chat disabled" + +#: menu.lua +msgid "Foste para o bate-papo publico" +msgstr "You went to the public chat" + +#: menu.lua +msgid "Foste para o bate-papo privado" +msgstr "You went to the private chat" + +#: menu.lua +msgid "Precisa entrar em um grupo" +msgstr "You need to join a group" + +#: menu.lua +msgid "Foste para o bate-papo do grupo @1" +msgstr "You went to group chat" + +#: menu.lua +msgid "Bate-Papo" +msgstr "Chat" + +#: menu.lua +msgid "Abrir Menu" +msgstr "Open Menu" + +#: chat.lua +msgid "Usar chat como administrador" +msgstr "Use the chat how administrator" + +#: chat.lua +msgid "Usar chat como moderador" +msgstr "Use the chat how staff" + +#: chat.lua +msgid "ADMIN" +msgstr "ADMIN" + +#: chat.lua +msgid "MODERADOR" +msgstr "STAFF" diff --git a/locale/multichat.en.tr b/locale/multichat.en.tr new file mode 100644 index 0000000..882fd8d --- /dev/null +++ b/locale/multichat.en.tr @@ -0,0 +1,32 @@ +### Arquivo gerado por multichat apartir de en.po +# textdomain: multichat +Exit=Exit +in Group=in Group +Disabled=Disabled +You went to the private chat=You went to the private chat +Group=Group +Ignored=Ignored +Chat=Chat +Remove=Remove +Currently=Currently +ADMIN=ADMIN +Private=Private +You went to the public chat=You went to the public chat +Sound=Sound +STAFF=STAFF +Error=Error +Add=Add +You need to join a group=You need to join a group +Return=Return +Use the chat how staff=Use the chat how staff +You went to group chat=You went to group chat +in Public=in Public +Open Menu=Open Menu +Speaking=Speaking +in Private=in Private +Public=Public +My Chat=My Chat +My Private Chat=My Private Chat +Use the chat how administrator=Use the chat how administrator +Chat disabled=Chat disabled +Disable=Disable diff --git a/locale/multichat.pt.tr b/locale/multichat.pt.tr new file mode 100644 index 0000000..9899b4a --- /dev/null +++ b/locale/multichat.pt.tr @@ -0,0 +1,32 @@ +### Arquivo gerado por multichat apartir de pt.po +# textdomain: multichat +Exit=Sair +in Group=em Grupo +Disabled=Desativado +You went to the private chat=Foste para o bate-papo privado +Group=Grupo +Ignored=Ignorados +Chat=Bate-Papo +Remove=Remover +Currently=Atualmente +ADMIN=ADMIN +Private=Privado +You went to the public chat=Foste para o bate-papo publico +Sound=Som +STAFF=MODERADOR +Error=Erro +Add=Adicionar +You need to join a group=Precisa entrar em um grupo +Return=Voltar +Use the chat how staff=Usar chat como moderador +You went to group chat=Foste para o bate-papo do grupo @1 +in Public=em Publico +Open Menu=Abrir Menu +Speaking=Conversando +in Private=em Privado +Public=Publico +My Chat=Meu Bate-Papo +My Private Chat=Meu Bate-Papo Privado +Use the chat how administrator=Usar chat como administrador +Chat disabled=Bate-papo desativado +Disable=Desativar diff --git a/locale/pt.mo b/locale/pt.mo new file mode 100644 index 0000000000000000000000000000000000000000..4367ebd405f7ff89328ee593eee29062d0b9d0bd GIT binary patch literal 1816 zcmeH_J!lj`6vxLHzs|&u7>yrM$Jm%+;$4g}TsZXNoJp_{VRAd38*X=&+1a3= zAXr#gScrvoqK%DWp%5z@8!HP%kU$zs3kAi_|8pk^3h6C;?3>@4kA3g`XLq5k`7VPU zgm=Q**D%%%wlraYJq6c+&%g}$0^9_?cJsGx{sC;q`Xaa){ONV;Ewr27>}x<7(=*jEgs z`zJ`cnvjgx3PSd>;q$TmaLPeOy^zsas!v+UDEBUS2Ye5la#NqwOB(hUPh{I@D3;3OXIXK^_=cBNn6RSf*L)pH!-_VMjX;G~ zu_0-dsK`jCQG|$lDwfutlb&X$bvUO?EJMVlmF1<-uwi2~8_}^}aJ5*PsIsz3_=<)BIF?v?jtQhyiG%gw6CeJff6=`EdIj;Mj7)t7~nABLVOo*zQ z^XZT%;fC|PH=7#}*?!S`g6DGi<9#A~ESt@okzqZNbtNX14Deogyga;;J=c@X;FDV1 zgqXY literal 0 HcmV?d00001 diff --git a/locale/pt.po b/locale/pt.po new file mode 100644 index 0000000..647d5e0 --- /dev/null +++ b/locale/pt.po @@ -0,0 +1,139 @@ +# 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-06-27 11:41-0300\n" +"PO-Revision-Date: 2018-06-27 11:54-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" + +#: menu.lua +msgid "Atualmente" +msgstr "Atualmente" + +#: menu.lua +msgid "em Publico" +msgstr "em Publico" + +#: menu.lua +msgid "Desativado" +msgstr "Desativado" + +#: menu.lua +msgid "em Privado" +msgstr "em Privado" + +#: menu.lua +msgid "em Grupo" +msgstr "em Grupo" + +#: menu.lua +msgid "Erro" +msgstr "Erro" + +#: menu.lua +msgid "Meu Bate-Papo" +msgstr "Meu Bate-Papo" + +#: menu.lua +msgid "Som" +msgstr "Som" + +#: menu.lua +msgid "Sair" +msgstr "Sair" + +#: menu.lua +msgid "Desativar" +msgstr "Desativar" + +#: menu.lua +msgid "Publico" +msgstr "Publico" + +#: menu.lua +msgid "Privado" +msgstr "Privado" + +#: menu.lua +msgid "Grupo" +msgstr "Grupo" + +#: menu.lua +msgid "Meu Bate-Papo Privado" +msgstr "Meu Bate-Papo Privado" + +#: menu.lua +msgid "Voltar" +msgstr "Voltar" + +#: menu.lua +msgid "Ignorados" +msgstr "Ignorados" + +#: menu.lua +msgid "Adicionar" +msgstr "Adicionar" + +#: menu.lua +msgid "Remover" +msgstr "Remover" + +#: menu.lua +msgid "Conversando" +msgstr "Conversando" + +#: menu.lua +msgid "Bate-papo desativado" +msgstr "Bate-papo desativado" + +#: menu.lua +msgid "Foste para o bate-papo publico" +msgstr "Foste para o bate-papo publico" + +#: menu.lua +msgid "Foste para o bate-papo privado" +msgstr "Foste para o bate-papo privado" + +#: menu.lua +msgid "Precisa entrar em um grupo" +msgstr "Precisa entrar em um grupo" + +#: menu.lua +msgid "Foste para o bate-papo do grupo @1" +msgstr "Foste para o bate-papo do grupo @1" + +#: menu.lua +msgid "Bate-Papo" +msgstr "Bate-Papo" + +#: menu.lua +msgid "Abrir Menu" +msgstr "Abrir Menu" + +#: chat.lua +msgid "Usar chat como administrador" +msgstr "Usar chat como administrador" + +#: chat.lua +msgid "Usar chat como moderador" +msgstr "Usar chat como moderador" + +#: chat.lua +msgid "ADMIN" +msgstr "ADMIN" + +#: chat.lua +msgid "MODERADOR" +msgstr "MODERADOR" diff --git a/locale/template.pot b/locale/template.pot new file mode 100644 index 0000000..cbe84c9 --- /dev/null +++ b/locale/template.pot @@ -0,0 +1,138 @@ +# 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-06-27 11:41-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" + +#: menu.lua +msgid "Atualmente" +msgstr "" + +#: menu.lua +msgid "em Publico" +msgstr "" + +#: menu.lua +msgid "Desativado" +msgstr "" + +#: menu.lua +msgid "em Privado" +msgstr "" + +#: menu.lua +msgid "em Grupo" +msgstr "" + +#: menu.lua +msgid "Erro" +msgstr "" + +#: menu.lua +msgid "Meu Bate-Papo" +msgstr "" + +#: menu.lua +msgid "Som" +msgstr "" + +#: menu.lua +msgid "Sair" +msgstr "" + +#: menu.lua +msgid "Desativar" +msgstr "" + +#: menu.lua +msgid "Publico" +msgstr "" + +#: menu.lua +msgid "Privado" +msgstr "" + +#: menu.lua +msgid "Grupo" +msgstr "" + +#: menu.lua +msgid "Meu Bate-Papo Privado" +msgstr "" + +#: menu.lua +msgid "Voltar" +msgstr "" + +#: menu.lua +msgid "Ignorados" +msgstr "" + +#: menu.lua +msgid "Adicionar" +msgstr "" + +#: menu.lua +msgid "Remover" +msgstr "" + +#: menu.lua +msgid "Conversando" +msgstr "" + +#: menu.lua +msgid "Bate-papo desativado" +msgstr "" + +#: menu.lua +msgid "Foste para o bate-papo publico" +msgstr "" + +#: menu.lua +msgid "Foste para o bate-papo privado" +msgstr "" + +#: menu.lua +msgid "Precisa entrar em um grupo" +msgstr "" + +#: menu.lua +msgid "Foste para o bate-papo do grupo @1" +msgstr "" + +#: menu.lua +msgid "Bate-Papo" +msgstr "" + +#: menu.lua +msgid "Abrir Menu" +msgstr "" + +#: chat.lua +msgid "Usar chat como administrador" +msgstr "" + +#: chat.lua +msgid "Usar chat como moderador" +msgstr "" + +#: chat.lua +msgid "ADMIN" +msgstr "" + +#: chat.lua +msgid "MODERADOR" +msgstr "" diff --git a/menu.lua b/menu.lua index bbd7b8a..0b83627 100644 --- a/menu.lua +++ b/menu.lua @@ -10,6 +10,8 @@ ]] +local S = multichat.S + -- Remover grupo de um jogador offline local remover_grupo = function(name) multichat.salas[name] = nil @@ -21,27 +23,27 @@ multichat.acessar_menu = function(name) local player = minetest.get_player_by_name(name) local st = player:get_attribute("multichat_status") - local status = "Atualmente\n" + local status = S("Atualmente").."\n" -- Caso esteja no Publico if st == nil or st == "pub" then - status = status .. minetest.colorize("#00FF00", "em Publico") + status = status .. minetest.colorize("#00FF00", S("em Publico")) -- Caso esteja Desativado elseif st == "off" then - status = status .. minetest.colorize("#FF0000", "Desativado") + status = status .. minetest.colorize("#FF0000", S("Desativado")) -- Caso esteja no Grupo Privado elseif st == "grupo" then - status = status .. minetest.colorize("#3366FF", "em Privado") + status = status .. minetest.colorize("#3366FF", S("em Privado")) -- Caso esteja no Grupo da Guilda elseif st == "guilda" then - status = status .. minetest.colorize("#3366FF", "em Grupo") + status = status .. minetest.colorize("#3366FF", S("em Grupo")) -- Caso nenhuma situação prevista else - status = status .. "Erro" + status = status .. S("Erro") end -- Avisos sonoros @@ -58,19 +60,19 @@ multichat.acessar_menu = function(name) formspec = formspec ..default.gui_bg ..default.gui_bg_img - .."label[0,0;Meu Bate-Papo \n"..status.."]" + .."label[0,0;"..S("Meu Bate-Papo").."\n"..status.."]" .."image[3,0;1,1;multichat_botao.png]" - .."checkbox[0,1;som;Som;"..st_som.."]" - .."checkbox[0,1.5;chamada;Chamada;"..st_chamada.."]" - .."button_exit[3,1.2;1,1;sair;Sair]" - .."button_exit[0,2.2;4,1;desativar;Desativar]" - .."button_exit[0,3.2;4,1;publico;Publico]" - .."button_exit[0,4.2;3.3,1;privado;Privado]" + .."checkbox[0,1;som;"..S("Som")..";"..st_som.."]" + .."checkbox[0,1.5;chamada;"..S("Chamada")..";"..st_chamada.."]" + .."button_exit[3,1.2;1,1;sair;"..S("Sair").."]" + .."button_exit[0,2.2;4,1;desativar;"..S("Desativar").."]" + .."button_exit[0,3.2;4,1;publico;"..S("Publico").."]" + .."button_exit[0,4.2;3.3,1;privado;"..S("Privado").."]" .."image_button[3.15,4.3;0.825,0.825;default_book_written.png;grupo;]" -- Botão de grupo if multichat.guild == true then - formspec = formspec .. "button_exit[0,5.2;4,1;guild;Guilda]" + formspec = formspec .. "button_exit[0,5.2;4,1;guild;"..S("Grupo").."]" end minetest.show_formspec(name, "multichat:menu", formspec) end @@ -113,19 +115,19 @@ local acessar_menu_grupo = function(name) minetest.show_formspec(name, "multichat:menu_grupo", "size[8,6]" ..default.gui_bg ..default.gui_bg_img - .."label[0,0;Meu Bate-Papo Privado]" - .."button[6.1,-0.1;2,1;voltar;Voltar]" + .."label[0,0;"..S("Meu Bate-Papo Privado").."]" + .."button[6.1,-0.1;2,1;voltar;"..S("Voltar").."]" - .."label[0,1.1;Ignorados]" + .."label[0,1.1;"..S("Ignorados").."]" .."textlist[0,1.6;3,4.5;online;"..st_online.."]" .."image[3.5,1.7;1,1;gui_furnace_arrow_bg.png^[transformR270]" - .."button[3.1,2.5;1.9,1;adicionar;Adicionar]" + .."button[3.1,2.5;1.9,1;adicionar;"..S("Adicionar").."]" - .."button[3.1,4.3;1.9,1;remover;Remover]" + .."button[3.1,4.3;1.9,1;remover;"..S("Remover").."]" .."image[3.5,5;1,1;gui_furnace_arrow_bg.png^[transformR90]" - .."label[4.85,1.1;Conversando]" + .."label[4.85,1.1;"..S("Conversando").."]" .."textlist[4.85,1.6;3,4.5;grupo;"..st_grupo.."]" ) end @@ -137,15 +139,15 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) -- Botao de desativar bate-papo if fields.desativar then player:set_attribute("multichat_status", "off") - minetest.chat_send_player(player:get_player_name(), "Bate-papo desativado") + minetest.chat_send_player(player:get_player_name(), S("Bate-papo desativado")) elseif fields.publico then player:set_attribute("multichat_status", "pub") - minetest.chat_send_player(player:get_player_name(), "Foste para o bate-papo publico") + minetest.chat_send_player(player:get_player_name(), S("Foste para o bate-papo publico")) elseif fields.privado then player:set_attribute("multichat_status", "grupo") - minetest.chat_send_player(player:get_player_name(), "Foste para o bate-papo privado") + minetest.chat_send_player(player:get_player_name(), S("Foste para o bate-papo privado")) elseif fields.grupo then acessar_menu_grupo(player:get_player_name()) @@ -156,10 +158,10 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) if multichat.mod_guild == "manipulus" then local grupo = manipulus.get_player_grupo(player:get_player_name()) if grupo == nil or manipulus.existe_grupo(grupo) == false then - minetest.chat_send_player(player:get_player_name(), "Precisa entrar em um grupo") + minetest.chat_send_player(player:get_player_name(), S("Precisa entrar em um grupo")) else player:set_attribute("multichat_status", "guilda") - minetest.chat_send_player(player:get_player_name(), "Foste para o bate-papo do grupo '"..grupo.."'") + minetest.chat_send_player(player:get_player_name(), S("Foste para o bate-papo do grupo @1", "'"..grupo.."'")) end end @@ -242,7 +244,7 @@ if mymenu then mymenu.register_tr(SS) -- Registrar botao - mymenu.register_button("multichat:abrir_menu", "Bate-Papo") + mymenu.register_button("multichat:abrir_menu", S("Bate-Papo")) -- Receber botao do inventario minetest.register_on_player_receive_fields(function(player, formname, fields) @@ -253,21 +255,21 @@ if mymenu then elseif sfinv then sfinv.register_page("multichat:menu", { - title = "Bate-Papo", + title = S("Bate-Papo"), get = function(self, player, context) - return sfinv.make_formspec(player, context, [[ - button[2.5,1.5;3,1;multichat:abrir_menu;Abrir Menu] - 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) + return sfinv.make_formspec(player, context, + "button[2.5,1.5;3,1;multichat:abrir_menu;"..S("Abrir Menu").."]" + .."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 }) 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..6c84c37 --- /dev/null +++ b/tradutor.lua @@ -0,0 +1,173 @@ +--[[ + Mod multichat 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("multichat") + +-- Tradução intllib +multichat.intllib = {} +multichat.intllib.S, multichat.intllib.NS = dofile(modpath.."/lib/intllib.lua") + +-- Configura tradutor opicional +multichat.S = multichat.intllib.S +multichat.NS = multichat.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 multichat.*.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 multichat apartir de "..file.."\n# textdomain: multichat\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/multichat."..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("multichat") +else + s = multichat.intllib.S +end + +multichat.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", "[Multichat] String "..dump(args[1]).." nao catalogada") + return s(...) +end + +-- Marcador e ajustador de strings traduziveis +if minetest.get_translator ~= nil then + multichat.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, multichat.S(a)) + else + table.insert(r, a) + end + end + + return multichat.s(unpack(r)) + + elseif type(args[1]) == "string" then + -- Não traduz caso faltem argumentos (devido strings ilustrativas) + return multichat.s(...) + + else + return args[1] + end + end +end + +-- Função que retorna a string inalterada para passar pela checagem +multichat.Sfake = function(s) return s end + +