From 6d294c63fd3175650fa65985b72996488eafd873 Mon Sep 17 00:00:00 2001 From: systeembeheerder <19684880+systeembeheerder@users.noreply.github.com> Date: Wed, 14 Feb 2024 21:38:23 +0100 Subject: [PATCH 1/8] add i18n to Snappass --- .gitignore | 4 + babel.cfg | 10 ++ snappass/main.py | 11 +- snappass/templates/base.html | 6 +- snappass/templates/confirm.html | 6 +- snappass/templates/expired.html | 6 +- snappass/templates/password.html | 8 +- snappass/templates/preview.html | 8 +- snappass/templates/set_password.html | 14 +-- .../translations/nl/LC_MESSAGES/messages.po | 112 ++++++++++++++++++ 10 files changed, 157 insertions(+), 28 deletions(-) create mode 100644 babel.cfg create mode 100644 snappass/translations/nl/LC_MESSAGES/messages.po diff --git a/.gitignore b/.gitignore index 6c53d83..ac9ab38 100644 --- a/.gitignore +++ b/.gitignore @@ -50,3 +50,7 @@ htmlcov/ # virtualenv venv/ ENV/ + +# Translatio catalogs +*.mo +*.pot diff --git a/babel.cfg b/babel.cfg new file mode 100644 index 0000000..d6a43f6 --- /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 snapppass/translations -l +[python: snappass/**.py] +[jinja2: snappass/templates/**.html] + diff --git a/snappass/main.py b/snappass/main.py index 0568154..17ec84c 100644 --- a/snappass/main.py +++ b/snappass/main.py @@ -5,18 +5,18 @@ import uuid import redis from cryptography.fernet import Fernet -from flask import abort, Flask, render_template, request, jsonify +from flask import abort, Flask, render_template, request, jsonify, g 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) HOST_OVERRIDE = os.environ.get('HOST_OVERRIDE', None) TOKEN_SEPARATOR = '~' - # Initialize Flask Application app = Flask(__name__) if os.environ.get('DEBUG'): @@ -25,6 +25,11 @@ 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', 'nl']) +babel = Babel(app, locale_selector=get_locale) + # Initialize Redis if os.environ.get('MOCK_REDIS'): from fakeredis import FakeStrictRedis @@ -56,7 +61,6 @@ def check_redis_alive(fn): return abort(500) return inner - def encrypt(password): """ Take a password string, encrypt it with Fernet symmetric encryption, @@ -212,6 +216,5 @@ def health_check(): def main(): app.run(host='0.0.0.0') - if __name__ == '__main__': main() diff --git a/snappass/templates/base.html b/snappass/templates/base.html index b199f42..1b8f910 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/nl/LC_MESSAGES/messages.po b/snappass/translations/nl/LC_MESSAGES/messages.po new file mode 100644 index 0000000..3618555 --- /dev/null +++ b/snappass/translations/nl/LC_MESSAGES/messages.po @@ -0,0 +1,112 @@ +# Dutch translations for PROJECT. +# Copyright (C) 2024 ORGANIZATION +# This file is distributed under the same license as the PROJECT project. +# FIRST AUTHOR , 2024. +# +msgid "" +msgstr "" +"Project-Id-Version: PROJECT VERSION\n" +"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" +"POT-Creation-Date: 2024-02-14 21:09+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:4 +msgid "Snappass - Share Secrets" +msgstr "" + +#: 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 +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/preview.html:7 +msgid "Secret" +msgstr "Wachtwoord" + +#: 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" + From 6d17603016d3a4ac07b2c542a30ed7ca5636d2ea Mon Sep 17 00:00:00 2001 From: Bert Roelofsen <19684880+systeembeheerder@users.noreply.github.com> Date: Fri, 16 Feb 2024 09:18:20 +0100 Subject: [PATCH 2/8] remove import of flask, g --- snappass/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snappass/main.py b/snappass/main.py index 17ec84c..2516884 100644 --- a/snappass/main.py +++ b/snappass/main.py @@ -5,7 +5,7 @@ import uuid import redis from cryptography.fernet import Fernet -from flask import abort, Flask, render_template, request, jsonify, g +from flask import abort, Flask, render_template, request, jsonify from redis.exceptions import ConnectionError from urllib.parse import quote_plus from urllib.parse import unquote_plus From d178664d0c80a89b509bd5db9253264529368102 Mon Sep 17 00:00:00 2001 From: Bert Roelofsen <19684880+systeembeheerder@users.noreply.github.com> Date: Fri, 16 Feb 2024 10:40:13 +0100 Subject: [PATCH 3/8] Add empty translations for de and es --- babel.cfg | 2 +- requirements.txt | 1 + snappass/main.py | 2 +- snappass/templates/base.html | 2 +- .../translations/de/LC_MESSAGES/messages.po | 106 ++++++++++++++++++ .../translations/es/LC_MESSAGES/messages.po | 106 ++++++++++++++++++ .../translations/nl/LC_MESSAGES/messages.po | 8 +- 7 files changed, 222 insertions(+), 5 deletions(-) create mode 100644 snappass/translations/de/LC_MESSAGES/messages.po create mode 100644 snappass/translations/es/LC_MESSAGES/messages.po diff --git a/babel.cfg b/babel.cfg index d6a43f6..37d5d57 100644 --- a/babel.cfg +++ b/babel.cfg @@ -4,7 +4,7 @@ # (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 snapppass/translations -l +# (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 1813bab..21ddc19 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 2516884..826c78f 100644 --- a/snappass/main.py +++ b/snappass/main.py @@ -27,7 +27,7 @@ app.config.update( # Set up Babel def get_locale(): - return request.accept_languages.best_match(['en', 'nl']) + return request.accept_languages.best_match(['en', 'es', 'de', 'nl']) babel = Babel(app, locale_selector=get_locale) # Initialize Redis diff --git a/snappass/templates/base.html b/snappass/templates/base.html index 1b8f910..c099f20 100644 --- a/snappass/templates/base.html +++ b/snappass/templates/base.html @@ -1,5 +1,5 @@ - + {{ _('Snappass - Share Secrets') }} diff --git a/snappass/translations/de/LC_MESSAGES/messages.po b/snappass/translations/de/LC_MESSAGES/messages.po new file mode 100644 index 0000000..5ff8192 --- /dev/null +++ b/snappass/translations/de/LC_MESSAGES/messages.po @@ -0,0 +1,106 @@ +# German translations for PROJECT. +# Copyright (C) 2024 ORGANIZATION +# This file is distributed under the same license as the PROJECT project. +# FIRST AUTHOR , 2024. +# +msgid "" +msgstr "" +"Project-Id-Version: PROJECT VERSION\n" +"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" +"POT-Creation-Date: 2024-02-16 10:38+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/templates/base.html:16 +msgid "Share Secret" +msgstr "" + +#: snappass/templates/confirm.html:6 +msgid "Share Secret Link" +msgstr "" + +#: snappass/templates/confirm.html:7 +msgid "" +"The secret has been temporarily saved. Send the following URL to your " +"intended recipient." +msgstr "" + +#: snappass/templates/confirm.html:14 +msgid "Copy to clipboard" +msgstr "" + +#: snappass/templates/expired.html:6 +msgid "Secret not found" +msgstr "" + +#: 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 "" + +#: 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 "" + +#: snappass/templates/preview.html:7 +msgid "Secret" +msgstr "" + +#: snappass/templates/preview.html:9 +msgid "You can only reveal the secret once!" +msgstr "" + +#: snappass/templates/preview.html:12 +msgid "Reveal secret" +msgstr "" + +#: snappass/templates/set_password.html:6 +msgid "Set Secret" +msgstr "" + +#: 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/templates/set_password.html:18 +msgid "Two Weeks" +msgstr "" + +#: snappass/templates/set_password.html:19 +msgid "Week" +msgstr "" + +#: snappass/templates/set_password.html:20 +msgid "Day" +msgstr "" + +#: snappass/templates/set_password.html:21 +msgid "Hour" +msgstr "" + +#: snappass/templates/set_password.html:26 +msgid "Generate URL" +msgstr "" + diff --git a/snappass/translations/es/LC_MESSAGES/messages.po b/snappass/translations/es/LC_MESSAGES/messages.po new file mode 100644 index 0000000..274350c --- /dev/null +++ b/snappass/translations/es/LC_MESSAGES/messages.po @@ -0,0 +1,106 @@ +# Spanish translations for PROJECT. +# Copyright (C) 2024 ORGANIZATION +# This file is distributed under the same license as the PROJECT project. +# FIRST AUTHOR , 2024. +# +msgid "" +msgstr "" +"Project-Id-Version: PROJECT VERSION\n" +"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" +"POT-Creation-Date: 2024-02-16 10:38+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/templates/base.html:16 +msgid "Share Secret" +msgstr "" + +#: snappass/templates/confirm.html:6 +msgid "Share Secret Link" +msgstr "" + +#: snappass/templates/confirm.html:7 +msgid "" +"The secret has been temporarily saved. Send the following URL to your " +"intended recipient." +msgstr "" + +#: snappass/templates/confirm.html:14 +msgid "Copy to clipboard" +msgstr "" + +#: snappass/templates/expired.html:6 +msgid "Secret not found" +msgstr "" + +#: 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 "" + +#: 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 "" + +#: snappass/templates/preview.html:7 +msgid "Secret" +msgstr "" + +#: snappass/templates/preview.html:9 +msgid "You can only reveal the secret once!" +msgstr "" + +#: snappass/templates/preview.html:12 +msgid "Reveal secret" +msgstr "" + +#: snappass/templates/set_password.html:6 +msgid "Set Secret" +msgstr "" + +#: 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/templates/set_password.html:18 +msgid "Two Weeks" +msgstr "" + +#: snappass/templates/set_password.html:19 +msgid "Week" +msgstr "" + +#: snappass/templates/set_password.html:20 +msgid "Day" +msgstr "" + +#: snappass/templates/set_password.html:21 +msgid "Hour" +msgstr "" + +#: snappass/templates/set_password.html:26 +msgid "Generate URL" +msgstr "" + diff --git a/snappass/translations/nl/LC_MESSAGES/messages.po b/snappass/translations/nl/LC_MESSAGES/messages.po index 3618555..bc77d63 100644 --- a/snappass/translations/nl/LC_MESSAGES/messages.po +++ b/snappass/translations/nl/LC_MESSAGES/messages.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PROJECT VERSION\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" -"POT-Creation-Date: 2024-02-14 21:09+0100\n" +"POT-Creation-Date: 2024-02-16 10:38+0100\n" "PO-Revision-Date: 2024-02-14 21:16+0100\n" "Last-Translator: \n" "Language: nl\n" @@ -18,9 +18,13 @@ msgstr "" "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 "" +msgstr "Snappass - Deel Wachtwoorden" #: snappass/templates/base.html:16 msgid "Share Secret" From 28c396e8598a41af0f5a9046e3b8c405b7b6f2e7 Mon Sep 17 00:00:00 2001 From: Bert Roelofsen <19684880+systeembeheerder@users.noreply.github.com> Date: Mon, 19 Feb 2024 10:05:30 +0100 Subject: [PATCH 4/8] Add German Translation --- .../translations/de/LC_MESSAGES/messages.po | 37 ++++++++++++------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/snappass/translations/de/LC_MESSAGES/messages.po b/snappass/translations/de/LC_MESSAGES/messages.po index 5ff8192..0ae3916 100644 --- a/snappass/translations/de/LC_MESSAGES/messages.po +++ b/snappass/translations/de/LC_MESSAGES/messages.po @@ -24,29 +24,31 @@ msgstr "de" #: snappass/templates/base.html:4 msgid "Snappass - Share Secrets" -msgstr "" +msgstr "Snappass - Passwort teilen" #: snappass/templates/base.html:16 msgid "Share Secret" -msgstr "" +msgstr "Passwort teilen" #: snappass/templates/confirm.html:6 msgid "Share Secret Link" -msgstr "" +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 msgid "Copy to clipboard" -msgstr "" +msgstr "In Zwischenablage kopieren" #: snappass/templates/expired.html:6 msgid "Secret not found" -msgstr "" +msgstr "Passwort nicht gefunden" #: snappass/templates/expired.html:7 msgid "" @@ -54,28 +56,32 @@ msgid "" " 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 dies" +"Die 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/preview.html:7 msgid "Secret" -msgstr "" +msgstr "Geheim" #: snappass/templates/preview.html:9 msgid "You can only reveal the secret once!" -msgstr "" +msgstr "Du kannst das Passwort nur einmal lüften!" #: snappass/templates/preview.html:12 msgid "Reveal secret" -msgstr "" +msgstr "Passwort lüften" #: snappass/templates/set_password.html:6 msgid "Set Secret" -msgstr "" +msgstr "Geheimen Schlüssel festlegen" #: snappass/templates/set_password.html:12 msgid "" @@ -83,24 +89,27 @@ msgid "" "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 "" +msgstr "Zwei Wochen" #: snappass/templates/set_password.html:19 msgid "Week" -msgstr "" +msgstr "Woche" #: snappass/templates/set_password.html:20 msgid "Day" -msgstr "" +msgstr "Tag" #: snappass/templates/set_password.html:21 msgid "Hour" -msgstr "" +msgstr "Stunde" #: snappass/templates/set_password.html:26 msgid "Generate URL" -msgstr "" +msgstr "URL generieren" From 9fdddab11bd8f6bf06f5957e827b7539dac69948 Mon Sep 17 00:00:00 2001 From: Bert Roelofsen <19684880+systeembeheerder@users.noreply.github.com> Date: Wed, 21 Feb 2024 08:29:19 +0100 Subject: [PATCH 5/8] fix missing bracket --- .gitignore | 2 +- snappass/templates/password.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index ac9ab38..35d44eb 100644 --- a/.gitignore +++ b/.gitignore @@ -51,6 +51,6 @@ htmlcov/ venv/ ENV/ -# Translatio catalogs +# Translation catalogs *.mo *.pot diff --git a/snappass/templates/password.html b/snappass/templates/password.html index 6b30f0d..1a31252 100644 --- a/snappass/templates/password.html +++ b/snappass/templates/password.html @@ -18,7 +18,7 @@
-

{{ _('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 %} From 4fffb9c1d59d7563b0dafc74195f6176c900ee34 Mon Sep 17 00:00:00 2001 From: Bert Roelofsen <19684880+systeembeheerder@users.noreply.github.com> Date: Thu, 22 Feb 2024 10:29:06 +0100 Subject: [PATCH 6/8] restore extra spaces --- snappass/main.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/snappass/main.py b/snappass/main.py index 826c78f..ab16b2d 100644 --- a/snappass/main.py +++ b/snappass/main.py @@ -17,6 +17,7 @@ URL_PREFIX = os.environ.get('URL_PREFIX', None) HOST_OVERRIDE = os.environ.get('HOST_OVERRIDE', None) TOKEN_SEPARATOR = '~' + # Initialize Flask Application app = Flask(__name__) if os.environ.get('DEBUG'): @@ -28,6 +29,8 @@ app.config.update( # 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 @@ -61,6 +64,7 @@ def check_redis_alive(fn): return abort(500) return inner + def encrypt(password): """ Take a password string, encrypt it with Fernet symmetric encryption, @@ -216,5 +220,6 @@ def health_check(): def main(): app.run(host='0.0.0.0') + if __name__ == '__main__': main() From 114b5af6c2602e16c819941b35fb5eb8d2ba5f4e Mon Sep 17 00:00:00 2001 From: Bert Roelofsen <19684880+systeembeheerder@users.noreply.github.com> Date: Thu, 22 Feb 2024 12:55:20 +0100 Subject: [PATCH 7/8] Add Spanish and fixup NL&DE --- .../translations/de/LC_MESSAGES/messages.po | 44 +++++++++----- .../translations/es/LC_MESSAGES/messages.po | 59 +++++++++++++------ .../translations/nl/LC_MESSAGES/messages.po | 22 +++++-- 3 files changed, 88 insertions(+), 37 deletions(-) diff --git a/snappass/translations/de/LC_MESSAGES/messages.po b/snappass/translations/de/LC_MESSAGES/messages.po index 0ae3916..41e4756 100644 --- a/snappass/translations/de/LC_MESSAGES/messages.po +++ b/snappass/translations/de/LC_MESSAGES/messages.po @@ -1,13 +1,13 @@ -# German translations for PROJECT. +# German translations for SNAPPASS. # Copyright (C) 2024 ORGANIZATION # This file is distributed under the same license as the PROJECT project. -# FIRST AUTHOR , 2024. +# systeembeheerder , 2024. # msgid "" msgstr "" "Project-Id-Version: PROJECT VERSION\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" -"POT-Creation-Date: 2024-02-16 10:38+0100\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" @@ -39,10 +39,10 @@ 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." +"Das Geheimnis wurde vorübergehend gespeichert. Senden Sie die folgende " +"URL an Ihre gewünschten Empfänger." -#: snappass/templates/confirm.html:14 +#: snappass/templates/confirm.html:14 snappass/templates/password.html:14 msgid "Copy to clipboard" msgstr "In Zwischenablage kopieren" @@ -56,21 +56,36 @@ msgid "" " 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 dies" -"Die URL enthielt nie ein Passwort, oder weil sie abgelaufen ist oder offengelegt wurde " +"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." +"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/preview.html:7 +#: 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!" @@ -89,9 +104,10 @@ msgid "" "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 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" diff --git a/snappass/translations/es/LC_MESSAGES/messages.po b/snappass/translations/es/LC_MESSAGES/messages.po index 274350c..f8d31dd 100644 --- a/snappass/translations/es/LC_MESSAGES/messages.po +++ b/snappass/translations/es/LC_MESSAGES/messages.po @@ -1,13 +1,13 @@ -# Spanish translations for PROJECT. +# Spanish translations for SNAPPASS. # Copyright (C) 2024 ORGANIZATION # This file is distributed under the same license as the PROJECT project. -# FIRST AUTHOR , 2024. +# systeembeheerder , 2024. # msgid "" msgstr "" "Project-Id-Version: PROJECT VERSION\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" -"POT-Creation-Date: 2024-02-16 10:38+0100\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" @@ -24,29 +24,31 @@ msgstr "es" #: snappass/templates/base.html:4 msgid "Snappass - Share Secrets" -msgstr "" +msgstr "Snappass - Compartir secretos" #: snappass/templates/base.html:16 msgid "Share Secret" -msgstr "" +msgstr "Compartir secretos" #: snappass/templates/confirm.html:6 msgid "Share Secret Link" -msgstr "" +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/confirm.html:14 snappass/templates/password.html:14 msgid "Copy to clipboard" -msgstr "" +msgstr "Copiar en el portapapeles" #: snappass/templates/expired.html:6 msgid "Secret not found" -msgstr "" +msgstr "Secreto no encontrado" #: snappass/templates/expired.html:7 msgid "" @@ -54,28 +56,45 @@ msgid "" " 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/preview.html:7 +#: 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 "" +msgstr "¡Solo puedes revelar el secreto una vez!" #: snappass/templates/preview.html:12 msgid "Reveal secret" -msgstr "" +msgstr "Revelar secreto" #: snappass/templates/set_password.html:6 msgid "Set Secret" -msgstr "" +msgstr "Establecer secreto" #: snappass/templates/set_password.html:12 msgid "" @@ -83,24 +102,28 @@ msgid "" "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 "" +msgstr "Dos semanas" #: snappass/templates/set_password.html:19 msgid "Week" -msgstr "" +msgstr "Semana" #: snappass/templates/set_password.html:20 msgid "Day" -msgstr "" +msgstr "Día" #: snappass/templates/set_password.html:21 msgid "Hour" -msgstr "" +msgstr "Hora" #: snappass/templates/set_password.html:26 msgid "Generate URL" -msgstr "" +msgstr "Generar URL" diff --git a/snappass/translations/nl/LC_MESSAGES/messages.po b/snappass/translations/nl/LC_MESSAGES/messages.po index bc77d63..b1a6a07 100644 --- a/snappass/translations/nl/LC_MESSAGES/messages.po +++ b/snappass/translations/nl/LC_MESSAGES/messages.po @@ -1,13 +1,13 @@ -# Dutch translations for PROJECT. +# Dutch translations for SNAPPASS. # Copyright (C) 2024 ORGANIZATION # This file is distributed under the same license as the PROJECT project. -# FIRST AUTHOR , 2024. +# systeembeheerder , 2024. # msgid "" msgstr "" "Project-Id-Version: PROJECT VERSION\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" -"POT-Creation-Date: 2024-02-16 10:38+0100\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" @@ -42,7 +42,7 @@ msgstr "" "Het wachtwoord is tijdelijk opgeslagen. Deel de volgende URL aan de " "bedoelde ontvanger." -#: snappass/templates/confirm.html:14 +#: snappass/templates/confirm.html:14 snappass/templates/password.html:14 msgid "Copy to clipboard" msgstr "Kopieer naar het klembord" @@ -67,10 +67,22 @@ msgstr "" "Als deze URL naar u is toegestuurd, controleer de spelling of vraag de " "verzender om een nieuw wachtwoord link te versturen." -#: snappass/templates/preview.html:7 +#: 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!" From 106ac26e26d5db471849fa4ab79c218ac3b8d40f Mon Sep 17 00:00:00 2001 From: Bert Roelofsen <19684880+systeembeheerder@users.noreply.github.com> Date: Fri, 23 Feb 2024 09:59:36 +0100 Subject: [PATCH 8/8] TIL flake8 :) --- snappass/main.py | 1 + 1 file changed, 1 insertion(+) diff --git a/snappass/main.py b/snappass/main.py index ab16b2d..d19eb1c 100644 --- a/snappass/main.py +++ b/snappass/main.py @@ -26,6 +26,7 @@ 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'])