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"