diff --git a/.gitignore b/.gitignore index 6c53d83..35d44eb 100644 --- a/.gitignore +++ b/.gitignore @@ -50,3 +50,7 @@ htmlcov/ # virtualenv venv/ ENV/ + +# Translation catalogs +*.mo +*.pot diff --git a/babel.cfg b/babel.cfg new file mode 100644 index 0000000..37d5d57 --- /dev/null +++ b/babel.cfg @@ -0,0 +1,10 @@ +# Update Translations: +# (venv) $ pybabel extract -F babel.cfg -o messages.pot . +# (venv) $ pybabel update -i messages.pot -d snappass/translations +# (venv) $ pybabel compile -d snappass/translations +# Add a new language: +# (venv) $ pybabel extract -F babel.cfg -o messages.pot . +# (venv) $ pybabel init -i messages.pot -d snappass/translations -l +[python: snappass/**.py] +[jinja2: snappass/templates/**.html] + diff --git a/requirements.txt b/requirements.txt index b7e17bb..36e0c67 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,3 +5,4 @@ Jinja2==3.1.2 MarkupSafe==2.1.1 redis==5.0.1 Werkzeug==3.0.1 +flask-babel diff --git a/snappass/main.py b/snappass/main.py index 0568154..d19eb1c 100644 --- a/snappass/main.py +++ b/snappass/main.py @@ -10,6 +10,7 @@ from redis.exceptions import ConnectionError from urllib.parse import quote_plus from urllib.parse import unquote_plus from distutils.util import strtobool +from flask_babel import Babel NO_SSL = bool(strtobool(os.environ.get('NO_SSL', 'False'))) URL_PREFIX = os.environ.get('URL_PREFIX', None) @@ -25,6 +26,14 @@ app.secret_key = os.environ.get('SECRET_KEY', 'Secret Key') app.config.update( dict(STATIC_URL=os.environ.get('STATIC_URL', 'static'))) + +# Set up Babel +def get_locale(): + return request.accept_languages.best_match(['en', 'es', 'de', 'nl']) + + +babel = Babel(app, locale_selector=get_locale) + # Initialize Redis if os.environ.get('MOCK_REDIS'): from fakeredis import FakeStrictRedis diff --git a/snappass/templates/base.html b/snappass/templates/base.html index b199f42..c099f20 100644 --- a/snappass/templates/base.html +++ b/snappass/templates/base.html @@ -1,7 +1,7 @@ - + - Snappass - Share Secrets + {{ _('Snappass - Share Secrets') }} @@ -13,7 +13,7 @@ diff --git a/snappass/templates/confirm.html b/snappass/templates/confirm.html index 7fe8b29..df28427 100644 --- a/snappass/templates/confirm.html +++ b/snappass/templates/confirm.html @@ -3,15 +3,15 @@ {% block content %}
- -

The secret has been temporarily saved. Send the following URL to your intended recipient.

+ +

{{ _('The secret has been temporarily saved. Send the following URL to your intended recipient.') }}

-
-

The secret has now been permanently deleted from the system, and the URL will no longer work. Refresh this page to verify.

+

{{ _('The secret has now been permanently deleted from the system, and the URL will no longer work. Refresh this page to verify.') }}

{% endblock %} diff --git a/snappass/templates/preview.html b/snappass/templates/preview.html index 1e54277..7b877b6 100644 --- a/snappass/templates/preview.html +++ b/snappass/templates/preview.html @@ -4,12 +4,12 @@
-

You can only reveal the secret once!

+

{{ _('You can only reveal the secret once!') }}

- +
@@ -20,4 +20,4 @@ -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/snappass/templates/set_password.html b/snappass/templates/set_password.html index d332ace..a05f733 100644 --- a/snappass/templates/set_password.html +++ b/snappass/templates/set_password.html @@ -3,27 +3,27 @@ {% block content %}
- +
- +
- +
diff --git a/snappass/translations/de/LC_MESSAGES/messages.po b/snappass/translations/de/LC_MESSAGES/messages.po new file mode 100644 index 0000000..41e4756 --- /dev/null +++ b/snappass/translations/de/LC_MESSAGES/messages.po @@ -0,0 +1,131 @@ +# German translations for SNAPPASS. +# Copyright (C) 2024 ORGANIZATION +# This file is distributed under the same license as the PROJECT project. +# systeembeheerder , 2024. +# +msgid "" +msgstr "" +"Project-Id-Version: PROJECT VERSION\n" +"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" +"POT-Creation-Date: 2024-02-22 11:01+0100\n" +"PO-Revision-Date: 2024-02-16 09:29+0100\n" +"Last-Translator: FULL NAME \n" +"Language: de\n" +"Language-Team: de \n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=utf-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Generated-By: Babel 2.14.0\n" + +#: snappass/templates/base.html:2 +msgid "en" +msgstr "de" + +#: snappass/templates/base.html:4 +msgid "Snappass - Share Secrets" +msgstr "Snappass - Passwort teilen" + +#: snappass/templates/base.html:16 +msgid "Share Secret" +msgstr "Passwort teilen" + +#: snappass/templates/confirm.html:6 +msgid "Share Secret Link" +msgstr "Geheimen Link teilen" + +#: snappass/templates/confirm.html:7 +msgid "" +"The secret has been temporarily saved. Send the following URL to your " +"intended recipient." +msgstr "" +"Das Geheimnis wurde vorübergehend gespeichert. Senden Sie die folgende " +"URL an Ihre gewünschten Empfänger." + +#: snappass/templates/confirm.html:14 snappass/templates/password.html:14 +msgid "Copy to clipboard" +msgstr "In Zwischenablage kopieren" + +#: snappass/templates/expired.html:6 +msgid "Secret not found" +msgstr "Passwort nicht gefunden" + +#: snappass/templates/expired.html:7 +msgid "" +"The requested URL was not found on the server. This could be because this" +" URL never contained a secret, or because it expired or was revealed " +"earlier." +msgstr "" +"Die angeforderte URL wurde auf dem Server nicht gefunden. Dies könnte " +"daran liegen, dass diesDie URL enthielt nie ein Passwort, oder weil sie " +"abgelaufen ist oder offengelegt wurde " + +#: snappass/templates/expired.html:8 +msgid "" +"If this URL was sent to you by someone, make sure to check your spelling " +"or ask the person who sent it to you to send a new secret." +msgstr "" +"Wenn Ihnen diese URL von jemandem gesendet wurde, überprüfen Sie " +"unbedingt Ihre Rechtschreibung oder bitten Sie die Person, die es Ihnen " +"geschickt hat, ein neues Passwort zu senden." + +#: snappass/templates/password.html:6 snappass/templates/preview.html:7 +msgid "Secret" +msgstr "Geheim" + +#: snappass/templates/password.html:7 +msgid "Save the following secret to a secure location." +msgstr "Speichern Sie dass folgende Passwort an einem sicheren Ort." + +#: snappass/templates/password.html:21 +msgid "" +"The secret has now been permanently deleted from the system, and the URL " +"will no longer work. Refresh this page to verify." +msgstr "" +" Dass Passwort wurde nun endgültig aus dem System gelöscht, und die URL " +"funktioniert nicht mehr. Aktualisieren Sie diese Seite, um dies zu " +"überprüfen." + +#: snappass/templates/preview.html:9 +msgid "You can only reveal the secret once!" +msgstr "Du kannst das Passwort nur einmal lüften!" + +#: snappass/templates/preview.html:12 +msgid "Reveal secret" +msgstr "Passwort lüften" + +#: snappass/templates/set_password.html:6 +msgid "Set Secret" +msgstr "Geheimen Schlüssel festlegen" + +#: snappass/templates/set_password.html:12 +msgid "" +"SnapPass allows you to share secrets in a secure, ephemeral way. Input a " +"single or multi-line secret, its expiration time, and click Generate URL." +" Share the one-time use URL with your intended recipient." +msgstr "" +"SnapPass ermöglicht es Ihnen, Passwörter auf sichere, kurzlebige Weise zu" +" teilen. Input a ein- oder mehrzeiliges Passwort, die Ablaufzeit und " +"klicken Sie auf URL generieren.Teilen Sie die URL für den einmaligen " +"Gebrauch mit dem beabsichtigten Empfänger." + +#: snappass/templates/set_password.html:18 +msgid "Two Weeks" +msgstr "Zwei Wochen" + +#: snappass/templates/set_password.html:19 +msgid "Week" +msgstr "Woche" + +#: snappass/templates/set_password.html:20 +msgid "Day" +msgstr "Tag" + +#: snappass/templates/set_password.html:21 +msgid "Hour" +msgstr "Stunde" + +#: snappass/templates/set_password.html:26 +msgid "Generate URL" +msgstr "URL generieren" + diff --git a/snappass/translations/es/LC_MESSAGES/messages.po b/snappass/translations/es/LC_MESSAGES/messages.po new file mode 100644 index 0000000..f8d31dd --- /dev/null +++ b/snappass/translations/es/LC_MESSAGES/messages.po @@ -0,0 +1,129 @@ +# Spanish translations for SNAPPASS. +# Copyright (C) 2024 ORGANIZATION +# This file is distributed under the same license as the PROJECT project. +# systeembeheerder , 2024. +# +msgid "" +msgstr "" +"Project-Id-Version: PROJECT VERSION\n" +"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" +"POT-Creation-Date: 2024-02-22 11:01+0100\n" +"PO-Revision-Date: 2024-02-16 09:29+0100\n" +"Last-Translator: FULL NAME \n" +"Language: es\n" +"Language-Team: es \n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=utf-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Generated-By: Babel 2.14.0\n" + +#: snappass/templates/base.html:2 +msgid "en" +msgstr "es" + +#: snappass/templates/base.html:4 +msgid "Snappass - Share Secrets" +msgstr "Snappass - Compartir secretos" + +#: snappass/templates/base.html:16 +msgid "Share Secret" +msgstr "Compartir secretos" + +#: snappass/templates/confirm.html:6 +msgid "Share Secret Link" +msgstr "Compartir enlace secreto" + +#: snappass/templates/confirm.html:7 +msgid "" +"The secret has been temporarily saved. Send the following URL to your " +"intended recipient." +msgstr "" +"El secreto se ha guardado temporalmente. Envíe la siguiente URL a " +"sudestinatario previsto." + +#: snappass/templates/confirm.html:14 snappass/templates/password.html:14 +msgid "Copy to clipboard" +msgstr "Copiar en el portapapeles" + +#: snappass/templates/expired.html:6 +msgid "Secret not found" +msgstr "Secreto no encontrado" + +#: snappass/templates/expired.html:7 +msgid "" +"The requested URL was not found on the server. This could be because this" +" URL never contained a secret, or because it expired or was revealed " +"earlier." +msgstr "" +"La URL solicitada no se encontró en el servidor. Esto podría deberse a " +"estoLa URL nunca contenía un secreto, o porque caducó o fue revelado " +"Antes." + +#: snappass/templates/expired.html:8 +msgid "" +"If this URL was sent to you by someone, make sure to check your spelling " +"or ask the person who sent it to you to send a new secret." +msgstr "" +"Si alguien te envió esta URL, asegúrate de revisar tu ortografíaO pídele " +"a la persona que te lo envió que te envíe un nuevo secreto." + +#: snappass/templates/password.html:6 snappass/templates/preview.html:7 +msgid "Secret" +msgstr "Secreto" + +#: snappass/templates/password.html:7 +msgid "Save the following secret to a secure location." +msgstr "Guarda el siguiente secreto en un lugar seguro." + +#: snappass/templates/password.html:21 +msgid "" +"The secret has now been permanently deleted from the system, and the URL " +"will no longer work. Refresh this page to verify." +msgstr "" +"El secreto ahora se ha eliminado permanentemente del sistema, y la URL Ya" +" no funcionará. Actualiza esta página para verificarlo." + +#: snappass/templates/preview.html:9 +msgid "You can only reveal the secret once!" +msgstr "¡Solo puedes revelar el secreto una vez!" + +#: snappass/templates/preview.html:12 +msgid "Reveal secret" +msgstr "Revelar secreto" + +#: snappass/templates/set_password.html:6 +msgid "Set Secret" +msgstr "Establecer secreto" + +#: snappass/templates/set_password.html:12 +msgid "" +"SnapPass allows you to share secrets in a secure, ephemeral way. Input a " +"single or multi-line secret, its expiration time, and click Generate URL." +" Share the one-time use URL with your intended recipient." +msgstr "" +"SnapPass te permite compartir secretos de forma segura y efímera. " +"Introduzca un secreto de una o varias líneas, su tiempo de caducidad y " +"haga clic en Generar URL.Comparta la URL de un solo uso con el " +"destinatario previsto\"" + +#: snappass/templates/set_password.html:18 +msgid "Two Weeks" +msgstr "Dos semanas" + +#: snappass/templates/set_password.html:19 +msgid "Week" +msgstr "Semana" + +#: snappass/templates/set_password.html:20 +msgid "Day" +msgstr "Día" + +#: snappass/templates/set_password.html:21 +msgid "Hour" +msgstr "Hora" + +#: snappass/templates/set_password.html:26 +msgid "Generate URL" +msgstr "Generar URL" + diff --git a/snappass/translations/nl/LC_MESSAGES/messages.po b/snappass/translations/nl/LC_MESSAGES/messages.po new file mode 100644 index 0000000..b1a6a07 --- /dev/null +++ b/snappass/translations/nl/LC_MESSAGES/messages.po @@ -0,0 +1,128 @@ +# Dutch translations for SNAPPASS. +# Copyright (C) 2024 ORGANIZATION +# This file is distributed under the same license as the PROJECT project. +# systeembeheerder , 2024. +# +msgid "" +msgstr "" +"Project-Id-Version: PROJECT VERSION\n" +"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" +"POT-Creation-Date: 2024-02-22 11:01+0100\n" +"PO-Revision-Date: 2024-02-14 21:16+0100\n" +"Last-Translator: \n" +"Language: nl\n" +"Language-Team: nl \n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=utf-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Generated-By: Babel 2.14.0\n" + +#: snappass/templates/base.html:2 +msgid "en" +msgstr "nl" + +#: snappass/templates/base.html:4 +msgid "Snappass - Share Secrets" +msgstr "Snappass - Deel Wachtwoorden" + +#: snappass/templates/base.html:16 +msgid "Share Secret" +msgstr "Stel wachtwoord in" + +#: snappass/templates/confirm.html:6 +msgid "Share Secret Link" +msgstr "Deel wachtwoord link" + +#: snappass/templates/confirm.html:7 +msgid "" +"The secret has been temporarily saved. Send the following URL to your " +"intended recipient." +msgstr "" +"Het wachtwoord is tijdelijk opgeslagen. Deel de volgende URL aan de " +"bedoelde ontvanger." + +#: snappass/templates/confirm.html:14 snappass/templates/password.html:14 +msgid "Copy to clipboard" +msgstr "Kopieer naar het klembord" + +#: snappass/templates/expired.html:6 +msgid "Secret not found" +msgstr "Wachtwoord niet gevonden" + +#: snappass/templates/expired.html:7 +msgid "" +"The requested URL was not found on the server. This could be because this" +" URL never contained a secret, or because it expired or was revealed " +"earlier." +msgstr "" +"De gevraagde URL is niet gevonden op de server. Dat kan omdat deze geen " +"wachtwoord bevat, het is verlopen of het al eerder getoond is." + +#: snappass/templates/expired.html:8 +msgid "" +"If this URL was sent to you by someone, make sure to check your spelling " +"or ask the person who sent it to you to send a new secret." +msgstr "" +"Als deze URL naar u is toegestuurd, controleer de spelling of vraag de " +"verzender om een nieuw wachtwoord link te versturen." + +#: snappass/templates/password.html:6 snappass/templates/preview.html:7 +msgid "Secret" +msgstr "Wachtwoord" + +#: snappass/templates/password.html:7 +msgid "Save the following secret to a secure location." +msgstr "Bewaar het wachtwoord op een veilige plek." + +#: snappass/templates/password.html:21 +msgid "" +"The secret has now been permanently deleted from the system, and the URL " +"will no longer work. Refresh this page to verify." +msgstr "" +"Het wachtwoord is permanent verwijderd van het systeem, de URL werkt niet" +" meer. Herlaad deze pagina ter verificatie" + +#: snappass/templates/preview.html:9 +msgid "You can only reveal the secret once!" +msgstr "Het wachtwoord wordt slechts eenmaal getoond!" + +#: snappass/templates/preview.html:12 +msgid "Reveal secret" +msgstr "Onthul wachtwoord" + +#: snappass/templates/set_password.html:6 +msgid "Set Secret" +msgstr "Stel wachtwoord in" + +#: snappass/templates/set_password.html:12 +msgid "" +"SnapPass allows you to share secrets in a secure, ephemeral way. Input a " +"single or multi-line secret, its expiration time, and click Generate URL." +" Share the one-time use URL with your intended recipient." +msgstr "" +"We stellen je in staat om wachtwoorden op een veilige, tijdelijke manier " +"te delen. Voer een enkel- of meerregelig wachwoord in, stel de vervaltijd" +" in, en klik op 'URL genereren'. Deel de eenmalig te gebruiken URL met de" +" beoogde ontvanger." + +#: snappass/templates/set_password.html:18 +msgid "Two Weeks" +msgstr "Twee weken" + +#: snappass/templates/set_password.html:19 +msgid "Week" +msgstr "Week" + +#: snappass/templates/set_password.html:20 +msgid "Day" +msgstr "Dag" + +#: snappass/templates/set_password.html:21 +msgid "Hour" +msgstr "Uur" + +#: snappass/templates/set_password.html:26 +msgid "Generate URL" +msgstr "URL genereren" +