From c2ccb14ffff0e45398365e19dfd2874307ddb943 Mon Sep 17 00:00:00 2001 From: Jesusaves Date: Sun, 23 Oct 2022 23:45:19 -0300 Subject: Initial commit --- web/all_news.bin | 1 + web/backupcopy | 129 ++++++++++++++++++++++++++++++++++ web/deploy.sh | 4 ++ web/feed.xml | 1 + web/fetch.py | 62 +++++++++++++++++ web/gameinfo.sh | 22 ++++++ web/index.bin | 1 + web/langs.txt | 5 ++ web/legacy | 51 ++++++++++++++ web/news.html | 1 + web/news_to_html.py | 91 ++++++++++++++++++++++++ web/newsfeed.py | 101 +++++++++++++++++++++++++++ web/nf_main.xml | 1 + web/oldupdatelang.py | 164 ++++++++++++++++++++++++++++++++++++++++++++ web/original.po | 170 +++++++++++++++++++++++++++++++++++++++++++++ web/template.po | 84 +++++++++++++++++++++++ web/updatelang.py | 190 +++++++++++++++++++++++++++++++++++++++++++++++++++ 17 files changed, 1078 insertions(+) create mode 100644 web/all_news.bin create mode 100755 web/backupcopy create mode 100755 web/deploy.sh create mode 100644 web/feed.xml create mode 100755 web/fetch.py create mode 100755 web/gameinfo.sh create mode 100644 web/index.bin create mode 100644 web/langs.txt create mode 100755 web/legacy create mode 100644 web/news.html create mode 100755 web/news_to_html.py create mode 100755 web/newsfeed.py create mode 100644 web/nf_main.xml create mode 100755 web/oldupdatelang.py create mode 100644 web/original.po create mode 100644 web/template.po create mode 100755 web/updatelang.py (limited to 'web') diff --git a/web/all_news.bin b/web/all_news.bin new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/web/all_news.bin @@ -0,0 +1 @@ + diff --git a/web/backupcopy b/web/backupcopy new file mode 100755 index 0000000..81601b0 --- /dev/null +++ b/web/backupcopy @@ -0,0 +1,129 @@ +#! /usr/bin/env python2.7 +# -*- coding: utf8 -*- +# +# Copyright (C) 2018 TMW-2 +# Author: Jesusalva + +import os + +defaultLang = "en" +rootPath = "../../web/" + +langs=[] +files={} +originals={} + +# Populates the basic arrays +def populate(): + # Populate langs + o=open("langs.txt", "r") + for i in o: + langs.append(i.replace('\n','')) + o.close() + + # Populate files + for i in os.listdir(rootPath): + if i.endswith(".php.en"): + print "Valid file: "+str(i) + files[i]={} + for x in langs: + files[i][x]={} + + print str(files) +# Write po files +def writePoFile(nf,lg): + a=open("po/"+lg+".po", "a") + f=open(rootPath+nf, "r") + + for line in f: + a.write("#, no-c-format\n") + a.write('msgid "%s"\n' % line.replace('\n', '')) + try: + if files[nf][lg][line] != line: + a.write('msgstr "%s"\n' % files[nf][lg][line].replace('\n','')) + else: + a.write('msgstr "%s"\n' % "") + except KeyError: + a.write('msgstr "%s"\n' % "") + + a.write('\n') + + a.close() + +# Creates/Loads stuff +def genreadPoFile(): + for a in langs: + print("Reading translations for "+a) + for i in files: + readPoFile(i,a) + +def generatePoFiles(): + for a in langs: + print("Updating po file for "+a) + xrv=open("po/"+a+".po", "w") + # Print header + xrv.write('\ +# Copyright (C) 2018 TMW2\n\ +#\n\ +\n\ +msgid ""\n\ +msgstr ""\n\ +"Project-Id-Version: TMW2\\n"\n\ +"MIME-Version: 1.0\\n"\n\ +"Content-Type: text/plain; charset=UTF-8\\n"\n\ +"Content-Transfer-Encoding: 8bit\\n"\n\ +\n\ +') + xrv.close() + + for i in files: + writePoFile(i,a) + +def generateLocal(): + for a in langs: + print("generating local file for "+a) + for i in files: + writeLocal(i,a) + +# Reads Po Files +def readPoFile(nf, lg): + try: + a=open("po/"+lg+".po", "r") + except: + a=open("po/"+lg+".po", "w") + a.close() + a=open("po/"+lg+".po", "r") + + ctx="" + for line in a: + if "msgid " in line: + ctx=line.replace('\n','') + if "msgstr " in line and ctx != "": + if line != 'msgstr ""\n': + files[nf][lg][ctx]=line.replace('\n', '') + else: + files[nf][lg][ctx]=ctx + ctx="" + a.close() + +def writeLocal(nf, lg): + a=open(rootPath+nf[:-2]+lg, 'w') + b=open(rootPath+nf, 'r') + + for line in b: + try: + a.write(files[nf][lg][line]) + except KeyError: + a.write(line) + + b.close() + a.close() + +# Mainframe: populate arrays +populate() + +# Mainframe: handle PO files +genreadPoFile() +generatePoFiles() +generateLocal() + diff --git a/web/deploy.sh b/web/deploy.sh new file mode 100755 index 0000000..65c3bd2 --- /dev/null +++ b/web/deploy.sh @@ -0,0 +1,4 @@ +./news_to_html.py +./newsfeed.py +#cp news.html ../../web/ +cp feed.xml ../../web/tmw2.org/ diff --git a/web/feed.xml b/web/feed.xml new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/web/feed.xml @@ -0,0 +1 @@ + diff --git a/web/fetch.py b/web/fetch.py new file mode 100755 index 0000000..c5fbeea --- /dev/null +++ b/web/fetch.py @@ -0,0 +1,62 @@ +#! /usr/bin/env python2.7 +# -*- coding: utf8 -*- +# +# Copyright (C) 2018 TMW-2 +# Author: Jesusalva + +from transifex.api import TransifexAPI +#import sys + +#if len(sys.argv) == 2: +# if sys.argv[1] == "AllFilesVerified": +# pass +# else: +# print("Rejected: Incorrect magic word.") +# exit(1) +#else: +# print("Rejected: As this script is VULNERABLE TO CODE INJECTION, you cannot run this command without verifying all files at Transifex first.") +# exit(1) +print("\033[1mThis script is VULNERABLE TO CODE INJECTION. Git diff before deploying!\033[0m") + +project='moubootaur-legends' + +print("Loading user credentials (login.txt/password.txt) from lang/ folder...") + +# Load credentials from login.txt and password.txt +login=open('../lang/login.txt', 'r') +for i in login: + username=i.replace('\n', '').replace('\r', '') + +login.close() + +passw=open('../lang/password.txt', 'r') +for i in passw: + password=i.replace('\n', '').replace('\r', '') + +passw.close() + +t=TransifexAPI(username, password, 'https://www.transifex.com') + +if (not t.ping): + print("ERROR: Ping failed, this may be due incorrect username/password in login.txt and password.txt. Ensure there is NO newline at the end of file.") + exit(1) + +if (not t.project_exists(project)): + print("ERROR: Invalid project name") + exit(1) + +# Load languages +langs=[] +vcx=open("langs.txt", "r") +for i in vcx: + if i != "en": + langs.append(i.replace('\n', '')) +vcx.close() + +# Fetch all translations and record them at in/ +for i in langs: + print("Fetching %s..." %(i)) + t.get_translation(project, 'website', i, 'po/'+str(i)+'.po') + +print("All translations were retrieved.") +print("Please sanitize files removing \"\\n\", or updatelang.py won't parse properly.") diff --git a/web/gameinfo.sh b/web/gameinfo.sh new file mode 100755 index 0000000..757ee96 --- /dev/null +++ b/web/gameinfo.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +echo "Deploying news file..." +scp -4 -P 22 feed.xml jesusalva@213.202.247.189:/home/jesusalva/http/ +scp -4 -P 22 ../update/news.txt jesusalva@213.202.247.189:/home/jesusalva/http/updates/ + +echo "Begin - Gameinfo updater. User input required." +cd ../../gameinfo-api + +cd serverdata +git pull --rebase -X theirs +cd .. + +cd clientdata +git pull --rebase -X theirs +cd .. + +git commit -a +git push + +echo "Gameinfo updated! Mission complete!" + diff --git a/web/index.bin b/web/index.bin new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/web/index.bin @@ -0,0 +1 @@ + diff --git a/web/langs.txt b/web/langs.txt new file mode 100644 index 0000000..c1cd357 --- /dev/null +++ b/web/langs.txt @@ -0,0 +1,5 @@ +pt-BR +fr +de +es +ru diff --git a/web/legacy b/web/legacy new file mode 100755 index 0000000..4629a06 --- /dev/null +++ b/web/legacy @@ -0,0 +1,51 @@ +#! /usr/bin/env python2.7 +# -*- coding: utf8 -*- +# +# Copyright (C) 2018 TMW-2 +# Author: Jesusalva + +import os +import re + +defaultLang = "en" + +rootPath = "../../web/" + +filt = re.compile(".+[.]php", re.IGNORECASE) + +allFiles=[] +langFiles = dict() +langs = [] # Current languages + +# Read languages +o=open("langs.txt", "r") +for i in o: + langs.append(i.replace('\n','')) +o.close() + +# Read PHP files, and create langFiles[i]["master"] +for i in os.listdir(rootPath): + if i.endswith(".php"): + langFiles[i]={} + o=open(rootPath+'/'+i, 'r') + for line in o: + langFiles[i]["master"]=line + o.close() + +# Sort each language for stuff +for a in langFiles: + for b in langs: + langFiles[a][b]=[] + + cnt=0 + pot=open("po/"+b+".po", "r") + for line in pot: + if "msgstr" in line: + abaco=str(line.replace('msgstr "','')[:-1]) + if abaco != "": + langFiles[a][b].append(abaco) + else: + langFiles[a][b].append(langFiles[a][master][cnt]) + cnt+=1 + + print str(langFiles[a][b]) diff --git a/web/news.html b/web/news.html new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/web/news.html @@ -0,0 +1 @@ + diff --git a/web/news_to_html.py b/web/news_to_html.py new file mode 100755 index 0000000..4015a62 --- /dev/null +++ b/web/news_to_html.py @@ -0,0 +1,91 @@ +#! /usr/bin/env python +# -*- coding: utf8 -*- +# +# Copyright (C) 2018 The Mana World 2 +# Author: Jonatas N. (Jesusalva) + +import datetime +date=str(datetime.date.today()) + +#date="2019-08-05" + +# Update the INDEX +i1=open("index.bin", "r") +i2=open("1index.bin", "w") +for i in i1: + i2.write(i) +i2.close() +i1.close() +i1=open("index.bin", "w") +i2=open("1index.bin", "r") +i1.write(date+'\n') +for i in i2: + i1.write(i) +i2.close() +i1.close() +i1=open("index.bin", "r") + +# Prepare to sort from newest to oldest +dt=open("all_news.bin", "r") +dc=open("backup.bin", "w") +for i in dt: + dc.write(i) +dc.close() +dt.close() +dt=open("all_news.bin", "w") +dc=open("backup.bin", "r") + +# Read news and prepare header +ns=open("../update/news.txt", "r") +dt.write("\n

"+date+"

\n\n") + +# Function to markup it, and strip new lines +def markup(r): + r=r.replace('##0', '') + r=r.replace('##1', '') + r=r.replace('##2', '') + r=r.replace('##3', '') + r=r.replace('##4', '') + r=r.replace('##5', '') + r=r.replace('##6', '') + r=r.replace('##7', '') + r=r.replace('##8', '') + r=r.replace('##9', '') + r=r.replace('##B', '') + r=r.replace('##b', '') + r=r.replace('[@@', '') + r=r.replace('@@]', '') + return r +def nn(r): + return r.replace('\n', '') + +# Write the news at all_news.bin, and then reload the backup. Finally, close the file +for i in ns: + dt.write(markup(i)+'
\n') +dt.write("

") +for i in dc: + dt.write(i) + +ns.close() +dt.close() +dc.close() + +# Write the final HTML page +wp=open("news.html", "w") +dt=open("all_news.bin", "r") + +wp.write("Server News") +wp.write("") +for i in i1: + wp.write('') +wp.write('
Archive
'+nn(i)+'

') + +for line in dt: + wp.write(nn(line)) +wp.write("") + +wp.close() +dt.close() +i1.close() + diff --git a/web/newsfeed.py b/web/newsfeed.py new file mode 100755 index 0000000..5840ca4 --- /dev/null +++ b/web/newsfeed.py @@ -0,0 +1,101 @@ +#! /usr/bin/env python +# -*- coding: utf8 -*- +# +# Copyright (C) 2018 The Mana World 2 +# Author: Jonatas N. (Jesusalva) + +import datetime +date=str(datetime.date.today()) +fulldate=str(datetime.datetime.utcnow().isoformat()) + +#date="2020-01-31" +#fulldate="2020-01-31T11:45:20.543750" + +# Open file (Dt) and export to "old". (Src) is current news +dt=open("nf_main.xml", "r") +old=[] +for line in dt: + old.append(line) +dt.close() +dt=open("nf_main.xml", "w") +src=open("../update/news.txt", "r") + + +# Read news and prepare header +ns=open("../update/news.txt", "r") + + +# Function to markup it, and strip new lines +def markup(r): + r=r.replace('##0', '') + r=r.replace('##1', '') + r=r.replace('##2', '') + r=r.replace('##3', '') + r=r.replace('##4', '') + r=r.replace('##5', '') + r=r.replace('##6', '') + r=r.replace('##7', '') + r=r.replace('##8', '') + r=r.replace('##9', '') + r=r.replace('##B', '') + r=r.replace('##b', '') + r=r.replace('[@@', '') + r=r.replace('@@]', '') + return r +def nn(r): + return r.replace('\n', '') + +# Write the news, and close that file +dt.write(' \n') +for i in src: + if ('##0 Actual Release: ##1' in i): + dt.write('\ + '+nn(i.replace('##0 Actual Release: ##1',''))+'\n\ + \n\ + '+fulldate+'\n\ + tag:tmw2.org,'+date+'\n\ + '+markup(i)+'

\n') +dt.write("]]>
\n
") + +dt.write('\n\n') + +for i in old: + dt.write(i) + +src.close() +dt.close() + +# Open main file as (Dt) and read from (Ns) +dt=open("feed.xml", "w") +ns=open("nf_main.xml", "r") + +# headers +dt.write('\ +\n\ +\n\ + TMW2\n\ + \n\ + \n\ +') +dt.write(' '+fulldate+'\n') +dt.write('\ + https://tmw2.org\n\ + \n\ + TMW2 Project\n\ + admin@tmw2.org\n\ + \n\ +') + +# Write data +for i in ns: + dt.write(i) + +# close +dt.write('\n') + +dt.close() +ns.close() + diff --git a/web/nf_main.xml b/web/nf_main.xml new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/web/nf_main.xml @@ -0,0 +1 @@ + diff --git a/web/oldupdatelang.py b/web/oldupdatelang.py new file mode 100755 index 0000000..e7a367a --- /dev/null +++ b/web/oldupdatelang.py @@ -0,0 +1,164 @@ +#! /usr/bin/env python3 +# -*- coding: utf8 -*- +# +# Copyright (C) 2018 TMW-2 +# Author: Jesusalva + +import os + +defaultLang = "en" +rootPath = "../../web/" + +langs=[] +files={} +originals={} +tm=["","\n"] + +def invalidline(line, filx="none"): + return (line.startswith("include ") or + line.startswith("") or + "
" in line or + "iframe" in line or + "header" in filx or + (line.startswith("

") and line.endswith("

\n")) or + (line.startswith("

") and line.endswith("

\n")) or + (line.startswith("
") and line.endswith("\n")) or
+            (line.startswith("    
") and line.endswith("\n")) or + line.replace('\n','') == "") + +# Populates the basic arrays +def populate(): + # Populate langs + o=open("langs.txt", "r") + for i in o: + langs.append(i.replace('\n','')) + o.close() + + # Populate files + for i in os.listdir(rootPath): + if i.endswith(".php.en"): + print("Valid file: "+str(i)) + files[i]={} + for x in langs: + files[i][x]={} + + #print(str(files)) + + +# Creates/Loads stuff +def genreadPoFile(): + for a in langs: + print("Reading translations for "+a) + for i in files: + readPoFile(i,a) + +def generatePoFiles(): + global tm + context=langs + context.append('en') + for a in langs: + print("Updating po file for "+a) + xrv=open("po/"+a+".po", "w") + # Prints header + xrv.write('\ +# Copyright (C) 2018 TMW2\n\ +#\n\ +\n\ +msgid ""\n\ +msgstr ""\n\ +"Project-Id-Version: TMW2\\n"\n\ +"MIME-Version: 1.0\\n"\n\ +"Content-Type: text/plain; charset=UTF-8\\n"\n\ +"Content-Transfer-Encoding: 8bit\\n"\n\ +\n\ +') + xrv.close() + + tm=[""] + for i in files: + writePoFile(i,a) + context.remove('en') + +def generateLocal(): + for a in langs: + print("generating local file for "+a) + for i in files: + writeLocal(i,a) + + + +# Write po files. TODO: WARNING: Some translations are getting overriden! +def writePoFile(nf,lg): + # Translation Memory, to prevent duplicates + global tm + + a=open("po/"+lg+".po", "a") + f=open(rootPath+nf, "r") + + for line in f: + if line in tm or invalidline(line, nf): + continue + else: + tm.append(line) + + a.write("#, no-c-format\n") + a.write('msgid "%s"\n' % line.replace('\n', '').replace('"','\\"')) + try: + if files[nf][lg][line.replace('\n', '')] != line.replace('\n', '') and files[nf][lg][line.replace('\n', '')] != "": + a.write('msgstr "%s"\n' % files[nf][lg][line.replace('\n', '')].replace('\n','').replace('"','\\"')) + else: + a.write('msgstr "%s"\n' % "") + except KeyError: + a.write('msgstr "%s"\n' % "") + + a.write('\n') + + a.close() + + +# Reads Po Files +def readPoFile(nf, lg): + try: + a=open("po/"+lg+".po", "r") + except: + a=open("po/"+lg+".po", "w") + a.close() + a=open("po/"+lg+".po", "r") + + ctx="" + for line in a: + if "msgid " in line: + ctx=line.replace('"\n','').replace('\\"','"').replace('msgid "', "") + if "msgstr " in line and ctx != "": + if line != 'msgstr ""\n': + files[nf][lg][ctx]=line.replace('"\n', '').replace('\\"','"').replace('msgstr "', "") + else: + files[nf][lg][ctx]=ctx + ctx="" + + a.close() + +def writeLocal(nf, lg): + a=open(rootPath+nf[:-2]+lg, 'w') + b=open(rootPath+nf, 'r') + + for line in b: + try: + a.write(files[nf][lg][line.replace('\n', '')]) + a.write('\n') + except KeyError: + a.write(line) + + b.close() + a.close() + +# Mainframe: populate arrays +populate() + +# Mainframe: handle PO files +genreadPoFile() +generatePoFiles() +generateLocal() + diff --git a/web/original.po b/web/original.po new file mode 100644 index 0000000..f27e280 --- /dev/null +++ b/web/original.po @@ -0,0 +1,170 @@ +# Copyright (C) 2018 TMW2 +# +# Translators: +# Jesusaves , 2018 +msgid "" +msgstr "" +"Project-Id-Version: TMW2\n" +"Last-Translator: Jesusaves , 2018\n" +"Language-Team: Portuguese (Brazil) (https://www.transifex.com/akaras/teams/959/pt_BR/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: pt_BR\n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" + +#, no-c-format +msgid "TMW-2: Monster World | Index Page" +msgstr "TMW-2: Mundo dos Monstros | Página Inicial" + +#, no-c-format +msgid "

TMW-2: Monster Wars

" +msgstr "

TMW-2: Guerra dos Monstros

" + +#, no-c-format +msgid "" +"

The Monster World (2) is an open source MMORPG project developed by " +"the community and for the community. We believe that players should be " +"rewarded for merit, and not for game time or luck. TMW2 runs in the ManaPlus" +" client, also opensource, and our game have its code database licensed under" +" GPL 3 and resources (GFX,SFX,etc) typically under CC-BY-SA, although GPL " +"content is also present.

" +msgstr "" +"

O Mundo dos Monstros (2) é um MMORPG de código aberto, desenvolvido pela " +"comunidade e para comunidade. Acreditamos que os jogadores devem ser " +"recompensados por mérito, e não por tempo de jogo ou sorte. TMW2 roda no " +"cliente ManaPlus, também de código aberto, e nosso jogo tem seu código na " +"licença GPL 3 e recursos (GFX, SFX, etc) tipicamente sobre CC-BY-SA, embora " +"conteúdo GPL também esteja presente.

" + +#, no-c-format +msgid "" +"

In this game, the player is given the opportunity to permanently " +"change the world and its story, affecting all players forever, mainly by " +"events and quests. The players are free to decide how they want the world to" +" develop, and their actions change the storyline, besides always being able " +"to join the Development Team.

" +msgstr "" +"

Nesse jogo, o jogador recebe a oportunidade de permanentemente modificar " +"o mundo e sua história, afetando todos os jogadores para sempre, " +"principalmente por eventos e quests. Os jogadores são livres para decidir " +"como querem que o mundo se desenvolva, e suas ações mudam a história, além " +"de sempre serem capazes de se unir a Equipe de Desenvolvimento.

" + +#, no-c-format +msgid "TMW-2: Monster World | Download Page" +msgstr "TMW-2: Mundo dos Monstros | Página de Download" + +#, no-c-format +msgid "

Downloading the Game

" +msgstr "

Baixando o Jogo

" + +#, no-c-format +msgid "

Downloading the Client

" +msgstr "

Baixando o Cliente

" + +#, no-c-format +msgid "

" +msgstr "

" + +#, no-c-format +msgid "" +" The first step is to download ManaPlus," +msgstr "" +" O primeiro passo é baixar o ManaPlus," + +#, no-c-format +msgid "" +" our game client. If you download from a repository, ensure the " +"version is" +msgstr "" +"nosso cliente de jogo. Se você baixar de um repositório, certifique-se que a" +" versão é" + +#, no-c-format +msgid " 1.7.x or greater. Older versions may present bugs." +msgstr "1.7.x ou superior. Versões mais antigas podem apresentar erros." + +#, no-c-format +msgid "

" +msgstr "

" + +#, no-c-format +msgid "

Adding the Server

" +msgstr "

Adicionando o Servidor

" + +#, no-c-format +msgid "" +" Once the game opens, a server list will show. Select “Add”. Insert a" +" server" +msgstr "" +"Quando o jogo abrir, uma lista de servidores será exibida. Clique em " +"\"Adicionar\". Insira um" + +#, no-c-format +msgid " name and description. The important data is as follow:" +msgstr "nome de servidor e descrição. Os dados importantes são esses:" + +#, no-c-format +msgid "
"
+msgstr "    
"
+
+#, no-c-format
+msgid "        Address: server.tmw2.org"
+msgstr "        Endereço: server.tmw2.org"
+
+#, no-c-format
+msgid "        Port: 6901"
+msgstr "Porta: 6901"
+
+#, no-c-format
+msgid "        Type: Evol2"
+msgstr "Tipo: Evol2"
+
+#, no-c-format
+msgid "    
" +msgstr "
" + +#, no-c-format +msgid "" +" You'll need to register before playing the game. Please use a valid " +"email" +msgstr "" +"Você precisará se registrar antes de jogar. Por favor utilize um endereço de" +" email válido" + +#, no-c-format +msgid "" +" address as if we need to email your password back to you, we will do" +" using" +msgstr "já que se precisarmos lhe enviar a sua senha de volta, o faremos" + +#, no-c-format +msgid " that email." +msgstr "utilizando esse email." + +#, no-c-format +msgid "

Troubleshooting

" +msgstr "

Solução de Problemas

" + +#, no-c-format +msgid "" +" Game official release is 2018-03-02. If we are past this date and " +"you're" +msgstr "" +"O lançamento oficial do jogo é 2018-03-02. Se essa data já passou e você" + +#, no-c-format +msgid "" +" getting a “servers unavailable” message, or is otherwise unable to " +"connect," +msgstr "" +"está recebendo uma mensagem de \"servidores indisponíveis\", ou não consegue" +" se conectar," + +#, no-c-format +msgid " please contact us so we may fix this issue." +msgstr "" +"por favor entre em contato conosco para que possamos corrigir esse problema." diff --git a/web/template.po b/web/template.po new file mode 100644 index 0000000..16ce842 --- /dev/null +++ b/web/template.po @@ -0,0 +1,84 @@ +# +msgid "" +msgstr "" +"Project-Id-Version: 1.0\n" +"Report-Msgid-Bugs-To: dev@tmw2.org\n" +"POT-Creation-Date: 2020-02-28 05:43-0300\n" +"PO-Revision-Date: 2020-02-28 05:43-0300\n" +"Last-Translator: TMW2 Team \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=utf-8\n" +"Content-Transfer-Encoding: 8bit\n" + +msgid "a string for testing" +msgstr "uma linha para testar" + +msgid "$s Online Players" +msgstr "$s Jogadores Online" + +msgid "Home" +msgstr "Início" + +msgid "Community" +msgstr "Comunidade" + +msgid "News" +msgstr "Notícias" + +msgid "Legal Notice" +msgstr "Nota Legal" + +msgid "Wiki & Info" +msgstr "Wiki & Info" + +msgid "Get involved" +msgstr "Se Involva" + +msgid "Making Art" +msgstr "Pixelart" + +msgid "MapMaking" +msgstr "Fazendo Mapas" + +msgid "Programming" +msgstr "Programação" + +msgid "Game Content" +msgstr "Conteúdo de Jogo" + +msgid "Music and SFX" +msgstr "Música e SFX" + +msgid "Item Viewer" +msgstr "Visualizador de Itens" + +msgid "Page not found" +msgstr "Página não encontrada" + +msgid "Get in touch with the community!" +msgstr "Entre em contato com a comunidade!" + +msgid "" +"We have a great community that expands over many platforms with people from all over the world. If you have a question or you need help with something don't hesitate to ask us.\n" +"Come visit us, and bring (or make) friends!" +msgstr "" +"We have a great community that expands over many platforms with people from all over the world. If you have a question or you need help with something don't hesitate to ask us.\n" +"Come visit us, and bring (or make) friends!" + +msgid "Social Platforms" +msgstr "Plataformas Sociais" + +msgid "Development" +msgstr "Desenvolvimento" + +msgid "Support us" +msgstr "Apoie-nos" + +msgid "You want to contribute in a way not listed above?" +msgstr "Você quer contribuir de uma maneira não listada acima?" + +msgid "No problem!" +msgstr "Sem problemas!" + +msgid "Reach out to us and tell us about it." +msgstr "Entre em contato conosco e nos fale sobre." diff --git a/web/updatelang.py b/web/updatelang.py new file mode 100755 index 0000000..2eba12c --- /dev/null +++ b/web/updatelang.py @@ -0,0 +1,190 @@ +#! /usr/bin/env python3 +# -*- coding: utf8 -*- +# +# Copyright (C) 2018~2020 TMW-2 +# Author: Jesusalva +# Note: This will "force" completion to 100%. Use review system! + +import copy, datetime +import polib, yaml + +defaultLang = "en" +rootPath = "../../site/i18n/" + +langs=[] +files={} +originals={} +tm={defaultLang: ["","\n"]} + +# Search for array[?]==search in an array of dicts +# Returns the dictionary, or returns "ERROR" +def dl_search(array, search): + for key in array.keys(): + if array[key] == search: + return key + raise Exception("Key not found") + +# For headers +def currentdate(): + dt=datetime.datetime.now() + + day=dt.timetuple()[2] + month=dt.timetuple()[1] + year=dt.timetuple()[0] + + hour=dt.timetuple()[3] + minute=dt.timetuple()[4] + #second=5 + #weekday=6 + #yearday=7 + + return "%04d-%02d-%02d %02d:%02d-0300" % (year, month, day, hour, minute) + + +def init(): + global defaultLang, rootPath, langs, files, originals, tm + # Populate langs + o=open("langs.txt", "r") + for i in o: + langs.append(i.replace('\n','')) + o.close() + + # Create the original file + f=open(rootPath+defaultLang+".yml", "r") + originals=yaml.load(f, Loader=yaml.FullLoader) # Dictionary + f.close() + + # We don't care with metadata + del originals["language_meta"] + + # Create each language's template + for i in langs: + files[str(i)]=copy.copy(originals) + tm[str(i)]=["","\n"] + + """ + # Do the reading for each language + for i in langs: + f=open(rootpath+i+".yml", "r") + files[str(i)]=yaml.load(f, Loader=yaml.FullLoader) # Dictionary + f.close() + """ + +# [OK] Returns name from language code +def lgname(lg): + if lg == "en": + return "English" + elif lg == "pt-BR": + return "Português (Brasil)" + elif lg == "de": + return "Deutsch" + elif lg == "fr": + return "François" + elif lg == "es": + return "Español" + elif lg == "ru": + return "Русский" + else: + return "Unknown %s" % lg + +# [OK] Entry +def poentry(org, ttl, comments): + return polib.POEntry(msgid=org, msgstr=ttl, comment=comments) + +# Creates/Loads stuff +def generatePoFiles(): + global tm + context=copy.copy(langs) + context.append('en') + for lg in context: + print("Updating po file for "+lg) + po=polib.POFile() + po.metadata = { + 'Project-Id-Version': '1.0', + 'Report-Msgid-Bugs-To': 'dev@tmw2.org', + 'POT-Creation-Date': currentdate(), + 'PO-Revision-Date': currentdate(), + 'Last-Translator': 'TMW2 Team ', + 'MIME-Version': '1.0', + 'Content-Type': 'text/plain; charset=utf-8', + 'Content-Transfer-Encoding': '8bit', + } + + for key, speech in originals.items(): + # Translation Memory (no duplicates) + if speech in tm[lg]: + continue + tm[lg].append(speech) + + # Add to po file + if lg == "en": + po.append(poentry(speech, "", key)) + else: + po.append(poentry(speech, files[lg][key], key)) + + po.save("po/%s.po" % lg) + context.remove('en') + + + + + +# [OK] Reads Po Files +def readPoFile(lg): + try: + po=polib.pofile("po/"+lg+".po") + except: + a=open("po/"+lg+".po", "w") + a.close() + print("%s.po does not exist, not reading" % lg) + return + + print("%s Progress: %d%%" % (lgname(lg), po.percent_translated())) + + for entry in po: + #print("%s = %s" % (entry.msgid, entry.msgstr)) + + try: + if entry.msgstr != "": + dest=dl_search(files[lg], entry.msgid) + #print("[+] %s" % dest) + files[lg][dest]=entry.msgstr + else: + dest=dl_search(files[lg], entry.msgid) + #print("%s.%s IS EMPTY" % (lg, dest)) + try: + files[lg][dest]=originals[dest] + except: + print("%s - failed to obtain originals" % entry.msgid) + except: + print("%s - string was removed" % entry.msgstr) + +# [OK] Save the new YML file +def writeLocal(lg): + f=open(rootPath+lg+".yml", 'w') + f.write("# THIS FILE WAS GENERATED AUTOMATICALLY\n#EDITING IT WILL HAVE NO EFFECT\n\n") + files[lg]["language_meta"]={"code": lg, "name": lgname(lg)} + yaml.dump(files[lg], f) + f.close() + + + + + + + + + + + +# Mainframe: setup +init() + +# Save translations to their YML files +for lg in langs: + readPoFile(lg) + writeLocal(lg) + +# Mainframe: handle PO files +generatePoFiles() + -- cgit v1.2.3-70-g09d2