Merge pull request #330 from systeembeheerder/i18n

add i18n to Snappass
This commit is contained in:
Yuping Li 2024-02-23 13:42:55 -08:00 committed by GitHub
commit 2b108d3630
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 436 additions and 24 deletions

4
.gitignore vendored
View file

@ -50,3 +50,7 @@ htmlcov/
# virtualenv
venv/
ENV/
# Translation catalogs
*.mo
*.pot

10
babel.cfg Normal file
View file

@ -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 <language_code>
[python: snappass/**.py]
[jinja2: snappass/templates/**.html]

View file

@ -5,3 +5,4 @@ Jinja2==3.1.2
MarkupSafe==2.1.1
redis==5.0.1
Werkzeug==3.0.1
flask-babel

View file

@ -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

View file

@ -1,7 +1,7 @@
<!DOCTYPE html>
<html lang="en">
<html lang="{{ _('en') }}">
<head>
<title>Snappass - Share Secrets</title>
<title>{{ _('Snappass - Share Secrets') }}</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
@ -13,7 +13,7 @@
<nav class="navbar navbar-default navbar-static-top">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" href="/">Share Secret</a>
<a class="navbar-brand" href="/">{{ _('Share Secret') }}</a>
</div>
</div>
</nav>

View file

@ -3,15 +3,15 @@
{% block content %}
<div class="container">
<section>
<div class="page-header"><h1>Share Secret Link</h1></div>
<p>The secret has been temporarily saved. Send the following URL to your intended recipient.</p>
<div class="page-header"><h1>{{ _('Share Secret Link') }}</h1></div>
<p>{{ _('The secret has been temporarily saved. Send the following URL to your intended recipient.') }}</p>
<div class="row">
<div class="col-sm-6 margin-bottom-10">
<input type="text" class="form-control" id="password-link" value="{{ password_link }}" readonly="readonly">
</div>
<div class="col-sm-6">
<button title="Copy to clipboard" type="button" class="btn btn-primary copy-clipboard-btn"
<button title="{{ _('Copy to clipboard') }}" type="button" class="btn btn-primary copy-clipboard-btn"
id="copy-clipboard-btn" data-clipboard-target="#password-link"
data-placement='bottom'>
<i class="fa fa-clipboard"></i>

View file

@ -3,9 +3,9 @@
{% block content %}
<div class="container">
<section>
<div class="page-header"><h1>Secret not found</h1></div>
<p class="lead">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.</p>
<p class="lead">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.</p>
<div class="page-header"><h1>{{ _('Secret not found') }}</h1></div>
<p class="lead">{{ _('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.') }}</p>
<p class="lead">{{ _('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.') }}</p>
</section>
</div>
{% endblock %}

View file

@ -3,22 +3,22 @@
{% block content %}
<div class="container">
<section>
<div class="page-header"><h1>Secret</h1></div>
<p>Save the following secret to a secure location.</p>
<div class="page-header"><h1>{{ _('Secret') }}</h1></div>
<p>{{ _('Save the following secret to a secure location.') }}</p>
<div class="row">
<div class="col-sm-6 margin-bottom-10">
<textarea class="form-control" rows="10" cols="50" id="password-text" name="password-text" readonly="readonly">{{ password }}</textarea>
</div>
<div class="col-sm-6">
<button title="Copy to clipboard" type="button" class="btn btn-primary copy-clipboard-btn"
<button title="{{ _('Copy to clipboard') }}" type="button" class="btn btn-primary copy-clipboard-btn"
id="copy-clipboard-btn" data-clipboard-target="#password-text"
data-placement='bottom'>
<i class="fa fa-clipboard"></i>
</button>
</div>
</div>
<p>The secret has now been permanently deleted from the system, and the URL will no longer work. Refresh this page to verify.</p>
<p>{{ _('The secret has now been permanently deleted from the system, and the URL will no longer work. Refresh this page to verify.') }}</p>
</section>
</div>
{% endblock %}

View file

@ -4,12 +4,12 @@
<div class="container">
<section>
<div class="page-header">
<h1>Secret</h1>
<h1>{{ _('Secret') }}</h1>
</div>
<p class="lead">You can only reveal the secret once!</p>
<p class="lead">{{ _('You can only reveal the secret once!') }}</p>
<div class="row">
<div class="col-sm-6 margin-bottom-10">
<button id="revealSecret" type="button" class="btn-lg btn-primary">Reveal secret</button>
<button id="revealSecret" type="button" class="btn-lg btn-primary">{{ _('Reveal secret') }}</button>
</div>
</div>
</section>
@ -20,4 +20,4 @@
<script src="{{ config.STATIC_URL }}/clipboardjs/clipboard.min.js"></script>
<script src="{{ config.STATIC_URL }}/snappass/scripts/clipboard_button.js"></script>
<script src="{{ config.STATIC_URL }}/snappass/scripts/preview.js"></script>
{% endblock %}
{% endblock %}

View file

@ -3,27 +3,27 @@
{% block content %}
<div class="container">
<section>
<div class="page-header"><h1>Set Secret</h1></div>
<div class="page-header"><h1>{{ _('Set Secret') }}</h1></div>
<div class="row">
<form role="form" id="password_create" method="post" autocomplete="off">
<div class="col-sm-6 margin-bottom-10">
<div class="input-group">
<span class="input-group-addon" id="basic-addon1"><span class="glyphicon glyphicon-lock" aria-hidden="true"></span></span>
<textarea rows="10" cols="50" id="password" name="password" autofocus="true" class="form-control" placeholder="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." aria-describedby="basic-addon1" autocomplete="off" required></textarea>
<textarea rows="10" cols="50" id="password" name="password" autofocus="true" class="form-control" placeholder="{{ _('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.') }}" aria-describedby="basic-addon1" autocomplete="off" required></textarea>
</div>
</div>
<div class="col-sm-2 margin-bottom-10">
<select class="form-control" name="ttl">
<option value="Two Weeks">Two Weeks</option>
<option value="Week" selected="selected">Week</option>
<option value="Day">Day</option>
<option value="Hour">Hour</option>
<option value="Two Weeks">{{ _('Two Weeks') }}</option>
<option value="Week" selected="selected">{{ _('Week') }}</option>
<option value="Day">{{ _('Day') }}</option>
<option value="Hour">{{ _('Hour') }}</option>
</select>
</div>
<div class="col-sm-4">
<button type="submit" class="btn btn-primary" id="submit">Generate URL</button>
<button type="submit" class="btn btn-primary" id="submit">{{ _('Generate URL') }}</button>
</div>
</form>
</div>

View file

@ -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 <systeembeheerder@users.noreply.github.com>, 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 <EMAIL@ADDRESS>\n"
"Language: de\n"
"Language-Team: de <LL@li.org>\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"

View file

@ -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 <systeembeheerder@users.noreply.github.com>, 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 <EMAIL@ADDRESS>\n"
"Language: es\n"
"Language-Team: es <LL@li.org>\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"

View file

@ -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 <systeembeheerder@users.noreply.github.com>, 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 <LL@li.org>\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"