[add] Added internacionalization. [translate] Translated to 'portuguese' (pt) and 'brazilian portuguese' (pt_BR).

This commit is contained in:
Lunovox 2024-11-18 19:06:00 -03:00
parent 5cf67a983b
commit 0e8034f30c
8 changed files with 537 additions and 1 deletions

View file

@ -19,7 +19,7 @@ modComputing.debug = function(text, playername)
else
core.log('error',
"["..modComputing.modname:upper()..":DEBUG] "
..modComputing.translate(
..(
"Unable to address debug for player '%s'."
):format(dump(playername))
)

70
locale/README.md Normal file
View file

@ -0,0 +1,70 @@
# TRANSLATES
To generate file '**template.pot**', did use terminal command:
````bash
cd computing
xgettext -n *.lua -L Lua --force-po --keyword=modComputing.translate --from-code=UTF-8 -o ./locale/template.pot
````
----
### Cria arquivo .po a partir de um arquivo de templante .pot
Sintaxe:
```bash
msginit --no-translator --no-wrap --locale=$LANG.UTF-8 --output-file=$LANG.po --input=$POT
```
Example to brasilian portuguese language (pt_BR):
```bash
msginit --no-translator --no-wrap --locale=pt_BR.UTF-8 --output-file=./locale/pt_BR.po --input=./locale/template.pot
```
----
### Atualiza arquivo ,po a partir de um arquivo de templante .pot
Sintaxe:
```bash
msgmerge --sort-output --no-wrap --update --backup=off $LANG.po $POT
```
Example to brasilian portuguese language (pt_BR):
```bash
msgmerge --sort-output --no-wrap --update --backup=off ./locale/pt_BR.po ./locale/template.pot
```
----
To edit '**.po**' files to your language use app poedit.:
Example of translation into brasilian portuguese language (pt_BR):
```bash
cd computing
sudo apt-get inatall poedit
poedit ./locale/pt_BR.po
```
* See others locales used: ca;cs;da;de;dv;eo;es;et;fr;hu;id;it;ja;jbo;kn;lt;ms;nb;nl;pl;pt;pt_BR;ro;ru;sl;sr_Cyrl;sv;sw;tr;uk
----
## Convert '.po' file to '.tr' file.
### COMMAND SAMPLE: TRANSLATE TO BRASILIAN PORTUGUESSE
````
cd ./locale/
lua po2tr.lua "computing" "pt_BR.po"
mv "pt_BR.tr" "computing.pt_BR.tr"
cat computing.pt_BR.tr | less
````
----
### TO ENABLE YOUR LANGUAGE IN MINETEST
* To enable the translate to brasilian portuguese language, write ```language = pt_BR``` in file "minetest.conf". Or write the command ```/set -n language pt_BR``` in game chat, and run again the minetest game.
> See more:
* https://forum.minetest.net/viewtopic.php?f=47&t=21974
* https://github.com/minetest/minetest/issues/8158
* https://gist.githubusercontent.com/mamchenkov/3690981/raw/8ebd48c2af20c893c164e8d5245d9450ad682104/update_translations.sh
* https://gitlab.com/4w/xtend/-/blob/master/xtend_default/tools/convert_po_file_to_tr_file/convert_po_file_to_tr_file.lua

20
locale/computing.pt.tr Normal file
View file

@ -0,0 +1,20 @@
# textdomain: computing
Sun=Dom
Mon=Seg
Tue=Ter
Wed=Qua
Thu=Qui
Fri=Sex
Sat=Sáb
SPR=PRI
SUM=VER
AUT=OUT
WIN=INV
@1-@2=@2/@1
Now this is the day @1°.=Agora este é o dia @1°.
FAILURE=FALHA
The maximum number of days is exactly '@1'!!!=O número máximo de dias é exatamente '@1'!!!
You do not have the '@1' privilege to execute this command!!!=Você não tem o privilégio '@1' para executar este comando!!!
@1, @2 @3=@1, @2 @3
msgid ""=Loja\nBanana
SMARTPHONE=ESPERTOFONE

20
locale/computing.pt_BR.tr Normal file
View file

@ -0,0 +1,20 @@
# textdomain: computing
Sun=Dom
Mon=Seg
Tue=Ter
Wed=Qua
Thu=Qui
Fri=Sex
Sat=Sáb
SPR=PRI
SUM=VER
AUT=OUT
WIN=INV
@1-@2=@2/@1
Now this is the day @1°.=Agora este é o dia @1°.
FAILURE=FALHA
The maximum number of days is exactly '@1'!!!=O número máximo de dias é exatamente '@1'!!!
You do not have the '@1' privilege to execute this command!!!=Você não tem o privilégio '@1' para executar este comando!!!
@1, @2 @3=@1, @2 @3
msgid ""=Loja\nBanana
SMARTPHONE=ESPERTOFONE

116
locale/po2tr.lua Normal file
View file

@ -0,0 +1,116 @@
#!/usr/bin/env luajit
-- Convert regular Gettext PO files to Minetest-specific TR files. If there is
-- already a TR file with the same name of the PO file except the file suffix
-- bneing .tr (or .TR) instead of .po (or .PO) then THIS FILE WILL BE
-- OVERWRITTEN WITHOUT INFORMATION OR A WAY TO RECOVER THE PREVIOUS FILE!
--
--
-- ▄██▄
-- ▀███
-- █
-- ▄▄▄▄▄ █
-- ▀▄ ▀▄ █ BACKUP
-- ▄▀▀▀▄ █▄▄▄▄█▄▄ ▄▀▀▀▄ █
-- █ ▄ █ █ ▄ █ █
-- ▀▄ ▄▀ ▀▄ ▄▀ █
-- █▀▀▀ ▀▀▀ █ █
-- █ █ █ ALL
-- ▄▀▄▄▀▄ █ ▄█▀█▀█▀█▀█▀█▄ █ █
-- █▒▒▒▒█ █ █████████████▄ █ █
-- █▒▒▒▒█ █ ██████████████▄ █ █
-- █▒▒▒▒█ █ ██████████████▄ █ █
-- █▒▒▒▒█ █ ██████████████ █ █
-- █▒▒▒▒█ █ ██████████████▀ █ █ THE
-- █▒▒▒▒█ ██ ██████████████ █ █
-- ▀████▀ ██▀█ █████████████▀ █▄█
-- ██ ██ ▀█ █▄█▄█▄█▄█▄█▀ ▄█▀
-- ██ ██ ▀█ ▄▀▓█
-- ██ ██ ▀█▀▄▄▄▄▄▄▄▄▄▀▀▓▓▓█
-- ████ █▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓█
-- ███ █▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓█ THINGS
-- ██ █▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓█
-- ██ █▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓█
-- ██ ▐█▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓█
-- ██ ▐█▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓█
-- ██ ▐█▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓█▌ !!!
-- ██ ▐█▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓█▌
-- ██ ▐█▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓█▌
-- ██ ▐█▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓█▌
--
--
-- The syntax of TR files according to the introducing forum post is:
--
-- # textdomain: namespace
-- original 1 = translation 1
-- original 2 = translation 2
-- original 3 = tralslation 3
-- original N = translation N
--
-- Where namespace should be the name of the mod. Following strings have to be
-- escaped using @.
--
-- String | Escape
-- -------+--------
-- `@` |`@@`
-- `=` |`@=`
-- `\n` |`@\n`
--
-- See https://forum.minetest.net/viewtopic.php?t=18349 for details.
-- Preparation
if arg[1] == nil or arg[2] == nil then
print('Provide the namesspace as first parameter')
print('Provide the path to the source PO file as second parameter')
print('Example: '..arg[0]..' mymod path/to/my/source.po')
return
end
local SEP = package.path:match('(%p)%?%.') or '/' -- wonky but hey ... :)
-- Assign parameters to local variables
local namespace = arg[1]
local po_file = arg[2]
local tr_file = arg[2]:gsub('po$', 'tr'):gsub('PO$', 'TR')
-- Get the translations through crude plaintext file parsing
local file_contents = {}
local translations = {}
local po_file_handle = io.open(po_file, 'rb')
if po_file_handle == nil then print('No base file found') return end
for line in po_file_handle:lines() do
if line:match('^msgid') or line:match('^msgstr') then
table.insert(file_contents, line)
end
end
local escape_string = function (s)
s = s:gsub('@([^%d])', '@@%1') -- All @ not followed by a number become @@
s = s:gsub('([^@]@)$', '%1@') -- An @ at the end of the string become @@
s = s:gsub('=', '@=') -- All = become @=
return s
end
for number,line_content in pairs(file_contents) do
if line_content:match('^msgid') then
local o = line_content:gsub('^msgid "(.+)"$', '%1')
local t = file_contents[number + 1]:gsub('^msgstr "(.+)"$', '%1')
if o ~= 'msgid = ""' and t ~= 'msgstr ""' then
table.insert(translations, escape_string(o)..'='..escape_string(t))
end
end
end
print(number)
po_file_handle:close()
-- Write translation to file
local tr_file_handle = io.open(tr_file, 'w+')
if tr_file_handle == nil then print('Could not open target file') return end
tr_file_handle:write('# textdomain: '..namespace, "\n")
for _,line in pairs(translations) do tr_file_handle:write(line, "\n") end
tr_file_handle:close()

104
locale/pt.po Normal file
View file

@ -0,0 +1,104 @@
# Portuguese translations for PACKAGE package.
# Copyright (C) 2024 THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# Automatically generated, 2024.
#
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-11-18 18:29-0300\n"
"PO-Revision-Date: 2024-11-18 18:29-0300\n"
"Last-Translator: Automatically generated\n"
"Language-Team: Lunovox Heavenfinder <lunovox@disroot.org>\n"
"Language: pt_BR\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
#: api.lua:98
msgid "Sun"
msgstr "Dom"
#: api.lua:99
msgid "Mon"
msgstr "Seg"
#: api.lua:100
msgid "Tue"
msgstr "Ter"
#: api.lua:101
msgid "Wed"
msgstr "Qua"
#: api.lua:102
msgid "Thu"
msgstr "Qui"
#: api.lua:103
msgid "Fri"
msgstr "Sex"
#: api.lua:104
msgid "Sat"
msgstr "Sáb"
#: api.lua:130
msgid "SPR"
msgstr "PRI"
#: api.lua:131
msgid "SUM"
msgstr "VER"
#: api.lua:132
msgid "AUT"
msgstr "OUT"
#: api.lua:133
msgid "WIN"
msgstr "INV"
#: api.lua:138
msgid "@1-@2"
msgstr "@2/@1"
#: api.lua:158
msgid "Now this is the day @1°."
msgstr "Agora este é o dia @1°."
#: functions.lua:5
msgid ""
"Forces the calendar to jump a certain number of days.\n"
"Maximum number of 112 days. Need 'settime' privilege."
msgstr ""
"Força o calendário a pular um certo número de dias.\n"
"Número máximo de 112 dias. Necessita do privilégio 'settime'."
#: functions.lua:20 functions.lua:33
msgid "FAILURE"
msgstr "FALHA"
#: functions.lua:22
msgid "The maximum number of days is exactly '@1'!!!"
msgstr "O número máximo de dias é exatamente '@1'!!!"
#: functions.lua:35
msgid "You do not have the '@1' privilege to execute this command!!!"
msgstr "Você não tem o privilégio '@1' para executar este comando!!!"
#: item_smartphone.lua:6
msgid "@1, @2 @3"
msgstr "@1, @2 @3"
#: item_smartphone.lua:23
msgid ""
"Banana\n"
"Store"
msgstr "Loja\nBanana"
#: item_smartphone.lua:34
msgid "SMARTPHONE"
msgstr "ESPERTOFONE"

104
locale/pt_BR.po Normal file
View file

@ -0,0 +1,104 @@
# Portuguese translations for PACKAGE package.
# Copyright (C) 2024 THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# Automatically generated, 2024.
#
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-11-18 18:29-0300\n"
"PO-Revision-Date: 2024-11-18 18:29-0300\n"
"Last-Translator: Automatically generated\n"
"Language-Team: Lunovox Heavenfinder <lunovox@disroot.org>\n"
"Language: pt_BR\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
#: api.lua:98
msgid "Sun"
msgstr "Dom"
#: api.lua:99
msgid "Mon"
msgstr "Seg"
#: api.lua:100
msgid "Tue"
msgstr "Ter"
#: api.lua:101
msgid "Wed"
msgstr "Qua"
#: api.lua:102
msgid "Thu"
msgstr "Qui"
#: api.lua:103
msgid "Fri"
msgstr "Sex"
#: api.lua:104
msgid "Sat"
msgstr "Sáb"
#: api.lua:130
msgid "SPR"
msgstr "PRI"
#: api.lua:131
msgid "SUM"
msgstr "VER"
#: api.lua:132
msgid "AUT"
msgstr "OUT"
#: api.lua:133
msgid "WIN"
msgstr "INV"
#: api.lua:138
msgid "@1-@2"
msgstr "@2/@1"
#: api.lua:158
msgid "Now this is the day @1°."
msgstr "Agora este é o dia @1°."
#: functions.lua:5
msgid ""
"Forces the calendar to jump a certain number of days.\n"
"Maximum number of 112 days. Need 'settime' privilege."
msgstr ""
"Força o calendário a pular um certo número de dias.\n"
"Número máximo de 112 dias. Necessita do privilégio 'settime'."
#: functions.lua:20 functions.lua:33
msgid "FAILURE"
msgstr "FALHA"
#: functions.lua:22
msgid "The maximum number of days is exactly '@1'!!!"
msgstr "O número máximo de dias é exatamente '@1'!!!"
#: functions.lua:35
msgid "You do not have the '@1' privilege to execute this command!!!"
msgstr "Você não tem o privilégio '@1' para executar este comando!!!"
#: item_smartphone.lua:6
msgid "@1, @2 @3"
msgstr "@1, @2 @3"
#: item_smartphone.lua:23
msgid ""
"Banana\n"
"Store"
msgstr "Loja\nBanana"
#: item_smartphone.lua:34
msgid "SMARTPHONE"
msgstr "ESPERTOFONE"

102
locale/template.pot Normal file
View file

@ -0,0 +1,102 @@
# 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: 2024-11-18 18:29-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=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: api.lua:98
msgid "Sun"
msgstr ""
#: api.lua:99
msgid "Mon"
msgstr ""
#: api.lua:100
msgid "Tue"
msgstr ""
#: api.lua:101
msgid "Wed"
msgstr ""
#: api.lua:102
msgid "Thu"
msgstr ""
#: api.lua:103
msgid "Fri"
msgstr ""
#: api.lua:104
msgid "Sat"
msgstr ""
#: api.lua:130
msgid "SPR"
msgstr ""
#: api.lua:131
msgid "SUM"
msgstr ""
#: api.lua:132
msgid "AUT"
msgstr ""
#: api.lua:133
msgid "WIN"
msgstr ""
#: api.lua:138
msgid "@1-@2"
msgstr ""
#: api.lua:158
msgid "Now this is the day @1°."
msgstr ""
#: functions.lua:5
msgid ""
"Forces the calendar to jump a certain number of days.\n"
"Maximum number of 112 days. Need 'settime' privilege."
msgstr ""
#: functions.lua:20 functions.lua:33
msgid "FAILURE"
msgstr ""
#: functions.lua:22
msgid "The maximum number of days is exactly '@1'!!!"
msgstr ""
#: functions.lua:35
msgid "You do not have the '@1' privilege to execute this command!!!"
msgstr ""
#: item_smartphone.lua:6
msgid "@1, @2 @3"
msgstr ""
#: item_smartphone.lua:23
msgid ""
"Banana\n"
"Store"
msgstr ""
#: item_smartphone.lua:34
msgid "SMARTPHONE"
msgstr ""