diff --git a/webapp/bin/tr_compile.py b/webapp/bin/tr_compile.py new file mode 100644 index 0000000..193dba8 --- /dev/null +++ b/webapp/bin/tr_compile.py @@ -0,0 +1,8 @@ +#!flask/bin/python +import os +import sys +if sys.platform == 'win32': + pybabel = 'flask\\Scripts\\pybabel' +else: + pybabel = 'pybabel' +os.system(pybabel + ' compile -d titanembeds/translations') \ No newline at end of file diff --git a/webapp/bin/tr_init.py b/webapp/bin/tr_init.py new file mode 100644 index 0000000..638ac62 --- /dev/null +++ b/webapp/bin/tr_init.py @@ -0,0 +1,13 @@ +#!flask/bin/python +import os +import sys +if sys.platform == 'win32': + pybabel = 'flask\\Scripts\\pybabel' +else: + pybabel = 'pybabel' +if len(sys.argv) != 2: + print("usage: tr_init ") + sys.exit(1) +os.system(pybabel + ' extract -F babel.cfg -k lazy_gettext -o messages.pot titanembeds') +os.system(pybabel + ' init -i messages.pot -d titanembeds/translations -l ' + sys.argv[1]) +os.unlink('messages.pot') \ No newline at end of file diff --git a/webapp/bin/tr_update.py b/webapp/bin/tr_update.py new file mode 100644 index 0000000..2260cb9 --- /dev/null +++ b/webapp/bin/tr_update.py @@ -0,0 +1,10 @@ +#!flask/bin/python +import os +import sys +if sys.platform == 'win32': + pybabel = 'flask\\Scripts\\pybabel' +else: + pybabel = 'pybabel' +os.system(pybabel + ' extract -F babel.cfg -k lazy_gettext -o messages.pot titanembeds') +os.system(pybabel + ' update -i messages.pot -d titanembeds/translations') +os.unlink('messages.pot') \ No newline at end of file diff --git a/webapp/titanembeds/app.py b/webapp/titanembeds/app.py index 0ecf5e4..c87a648 100644 --- a/webapp/titanembeds/app.py +++ b/webapp/titanembeds/app.py @@ -6,6 +6,7 @@ from titanembeds.utils import rate_limiter, discord_api, socketio, babel from .blueprints import api, user, admin, embed, gateway import os from titanembeds.database import get_administrators_list +from titanembeds.i18n import LANGUAGES try: import uwsgi @@ -41,6 +42,13 @@ app.register_blueprint(user.user, url_prefix="/user", template_folder="/template app.register_blueprint(embed.embed, url_prefix="/embed", template_folder="/templates") socketio.on_namespace(gateway.Gateway('/gateway')) +@babel.localeselector +def get_locale(): + param_lang = request.args.get("lang", None) + if param_lang in LANGUAGES: + return param_lang + return request.accept_languages.best_match(LANGUAGES.keys()) + @app.route("/") def index(): return render_template("index.html.j2") diff --git a/webapp/titanembeds/i18n.py b/webapp/titanembeds/i18n.py index c9e9ecf..ebda804 100644 --- a/webapp/titanembeds/i18n.py +++ b/webapp/titanembeds/i18n.py @@ -1,10 +1,4 @@ -from titanembeds.utils import babel -from flask import request - LANGUAGES = { - 'en-US': 'English' -} - -@babel.localeselector -def get_locale(): - return request.accept_languages.best_match(LANGUAGES.keys()) \ No newline at end of file + 'en_US': 'English', + 'nl': 'Nederlands' # Dutch +} \ No newline at end of file diff --git a/webapp/titanembeds/translations/nl/LC_MESSAGES/messages.po b/webapp/titanembeds/translations/nl/LC_MESSAGES/messages.po new file mode 100644 index 0000000..d952bd1 --- /dev/null +++ b/webapp/titanembeds/translations/nl/LC_MESSAGES/messages.po @@ -0,0 +1,151 @@ +msgid "" +msgstr "" +"Project-Id-Version: titanembeds\n" +"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" +"POT-Creation-Date: 2017-11-15 05:32+0000\n" +"PO-Revision-Date: 2017-11-15 19:06-0500\n" +"Last-Translator: jelle619\n" +"Language-Team: Dutch\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Generated-By: Babel 2.3.4\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"X-Generator: crowdin.com\n" +"X-Crowdin-Project: titanembeds\n" +"X-Crowdin-Language: nl\n" +"X-Crowdin-File: messages.pot\n" +"Language: nl_NL\n" + +#: titanembeds/blueprints/embed/embed.py:14 +msgid "Let's get to know each other! My name is Titan, what's yours?" +msgstr "Laten we elkaar leren kennen! Mijn naam is Titan, wat is de jouwe?" + +#: titanembeds/blueprints/embed/embed.py:15 +msgid "Hello and welcome!" +msgstr "Hallo en welkom!" + +#: titanembeds/blueprints/embed/embed.py:16 +msgid "What brings you here today?" +msgstr "Wat brengt jou hier vandaag?" + +#: titanembeds/blueprints/embed/embed.py:17 +msgid "....what do you expect this text to say?" +msgstr "...verwachtte je iets nuttigs van deze tekst?" + +#: titanembeds/blueprints/embed/embed.py:18 +msgid "Aha! ..made you look!" +msgstr "Aha! Ik heb je aandacht getrokken!" + +#: titanembeds/blueprints/embed/embed.py:19 +msgid "Initiating launch sequence..." +msgstr "Opstartsequentie initialiseren..." + +#: titanembeds/blueprints/embed/embed.py:20 +msgid "Captain, what's your option?" +msgstr "Kapitein, wat is je optie?" + +#: titanembeds/blueprints/embed/embed.py:21 +msgid "Alright, here's the usual~" +msgstr "Oké dan, hier komt het gebruikelijke~" + +#: titanembeds/templates/embed.html.j2:55 +msgid "Actions" +msgstr "Acties" + +#: titanembeds/templates/embed.html.j2:56 +msgid "Manage Guild Embed" +msgstr "Beheer Embed" + +#: titanembeds/templates/embed.html.j2:57 +msgid "Open Server on Discordapp" +msgstr "Open server in Discordapp" + +#: titanembeds/templates/embed.html.j2:61 +msgid "Channel Topic" +msgstr "Kanaalonderwerp" + +#: titanembeds/templates/embed.html.j2:66 +msgid "Channels" +msgstr "Kanalen" + +#: titanembeds/templates/embed.html.j2:71 +msgid "Online Server Members" +msgstr "Online Serverleden" + +#: titanembeds/templates/embed.html.j2:76 +msgid "Authenticated Embed Users" +msgstr "Geverifieerde Embed-gebruikers" + +#: titanembeds/templates/embed.html.j2:79 +msgid "Guest Embed Users" +msgstr "Gast Embed-gebruikers" + +#: titanembeds/templates/embed.html.j2:99 +msgid "Please choose one of the following methods to authenticate!" +msgstr "Kies alstublieft een van de volgende methoden om jezelf te verifiëren!" + +#: titanembeds/templates/embed.html.j2:105 +msgid "Discord Login" +msgstr "Discord Login" + +#: titanembeds/templates/embed.html.j2:106 +msgid "You will be invited into this server." +msgstr "Je zult lid worden van deze server." + +#: titanembeds/templates/embed.html.j2:110 +msgid "Of course, you also have the option to login by picking a temporary username for your current browsing session." +msgstr "Uiteraard heb je ook de optie om in te loggen door een tijdelijke gebruikersnaam voor je huidige browsersessie te kiezen." + +#: titanembeds/templates/embed.html.j2:112 +msgid "Username (Hit ENTER/RETURN key to confirm)" +msgstr "Gebruikersnaam (Gebruik ENTER/RETURN om te bevestigen)" + +#: titanembeds/templates/embed.html.j2:124 +msgid "Change Username" +msgstr "Verander Gebruikersnaam" + +#: titanembeds/templates/embed.html.j2:127 +msgid "Guests Accounts Only" +msgstr "Alleen voor Gastaccounts" + +#: titanembeds/templates/embed.html.j2:129 +msgid "Change your username (Hit ENTER/RETURN key to confirm)" +msgstr "Verander je gebruikersnaam (Gebruik ENTER/RETURN om te bevestigen)" + +#: titanembeds/templates/embed.html.j2:133 +msgid "Theme" +msgstr "Thema" + +#: titanembeds/templates/embed.html.j2:143 +msgid "Overwrite Current Embed Theme w/ User CSS" +msgstr "Overschrijf huidige thema van embed met uw aangepaste CSS" + +#: titanembeds/templates/embed.html.j2:147 +msgid "Notification Sound" +msgstr "Notificatiegeluid" + +#: titanembeds/templates/embed.html.j2:152 +msgid "New Messages" +msgstr "Nieuwe Berichten" + +#: titanembeds/templates/embed.html.j2:156 +msgid "Mentions" +msgstr "Vermeldingen" + +#: titanembeds/templates/embed.html.j2:160 +msgid "Nothing" +msgstr "Niets" + +#: titanembeds/templates/embed.html.j2:178 +msgid "Server Emoji" +msgstr "Server Emoji" + +#: titanembeds/templates/embed.html.j2:195 +msgid "Please login to post a message." +msgstr "Log alstublieft in om een bericht te plaatsen." + +#: titanembeds/templates/embed.html.j2:195 +msgid "Login" +msgstr "Log in" +