Skip to content

Commit 2b108d3

Browse files
authored
Merge pull request #330 from systeembeheerder/i18n
add i18n to Snappass
2 parents 415d5ee + 106ac26 commit 2b108d3

File tree

13 files changed

+436
-24
lines changed

13 files changed

+436
-24
lines changed

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,7 @@ htmlcov/
5050
# virtualenv
5151
venv/
5252
ENV/
53+
54+
# Translation catalogs
55+
*.mo
56+
*.pot

babel.cfg

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Update Translations:
2+
# (venv) $ pybabel extract -F babel.cfg -o messages.pot .
3+
# (venv) $ pybabel update -i messages.pot -d snappass/translations
4+
# (venv) $ pybabel compile -d snappass/translations
5+
# Add a new language:
6+
# (venv) $ pybabel extract -F babel.cfg -o messages.pot .
7+
# (venv) $ pybabel init -i messages.pot -d snappass/translations -l <language_code>
8+
[python: snappass/**.py]
9+
[jinja2: snappass/templates/**.html]
10+

requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ Jinja2==3.1.2
55
MarkupSafe==2.1.1
66
redis==5.0.1
77
Werkzeug==3.0.1
8+
flask-babel

snappass/main.py

+9
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from urllib.parse import quote_plus
1111
from urllib.parse import unquote_plus
1212
from distutils.util import strtobool
13+
from flask_babel import Babel
1314

1415
NO_SSL = bool(strtobool(os.environ.get('NO_SSL', 'False')))
1516
URL_PREFIX = os.environ.get('URL_PREFIX', None)
@@ -25,6 +26,14 @@
2526
app.config.update(
2627
dict(STATIC_URL=os.environ.get('STATIC_URL', 'static')))
2728

29+
30+
# Set up Babel
31+
def get_locale():
32+
return request.accept_languages.best_match(['en', 'es', 'de', 'nl'])
33+
34+
35+
babel = Babel(app, locale_selector=get_locale)
36+
2837
# Initialize Redis
2938
if os.environ.get('MOCK_REDIS'):
3039
from fakeredis import FakeStrictRedis

snappass/templates/base.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!DOCTYPE html>
2-
<html lang="en">
2+
<html lang="{{ _('en') }}">
33
<head>
4-
<title>Snappass - Share Secrets</title>
4+
<title>{{ _('Snappass - Share Secrets') }}</title>
55
<meta charset="UTF-8">
66
<meta name="viewport" content="width=device-width, initial-scale=1.0">
77

@@ -13,7 +13,7 @@
1313
<nav class="navbar navbar-default navbar-static-top">
1414
<div class="container">
1515
<div class="navbar-header">
16-
<a class="navbar-brand" href="/">Share Secret</a>
16+
<a class="navbar-brand" href="/">{{ _('Share Secret') }}</a>
1717
</div>
1818
</div>
1919
</nav>

snappass/templates/confirm.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
{% block content %}
44
<div class="container">
55
<section>
6-
<div class="page-header"><h1>Share Secret Link</h1></div>
7-
<p>The secret has been temporarily saved. Send the following URL to your intended recipient.</p>
6+
<div class="page-header"><h1>{{ _('Share Secret Link') }}</h1></div>
7+
<p>{{ _('The secret has been temporarily saved. Send the following URL to your intended recipient.') }}</p>
88
<div class="row">
99
<div class="col-sm-6 margin-bottom-10">
1010
<input type="text" class="form-control" id="password-link" value="{{ password_link }}" readonly="readonly">
1111
</div>
1212

1313
<div class="col-sm-6">
14-
<button title="Copy to clipboard" type="button" class="btn btn-primary copy-clipboard-btn"
14+
<button title="{{ _('Copy to clipboard') }}" type="button" class="btn btn-primary copy-clipboard-btn"
1515
id="copy-clipboard-btn" data-clipboard-target="#password-link"
1616
data-placement='bottom'>
1717
<i class="fa fa-clipboard"></i>

snappass/templates/expired.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
{% block content %}
44
<div class="container">
55
<section>
6-
<div class="page-header"><h1>Secret not found</h1></div>
7-
<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>
8-
<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>
6+
<div class="page-header"><h1>{{ _('Secret not found') }}</h1></div>
7+
<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>
8+
<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>
99
</section>
1010
</div>
1111
{% endblock %}

snappass/templates/password.html

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,22 @@
33
{% block content %}
44
<div class="container">
55
<section>
6-
<div class="page-header"><h1>Secret</h1></div>
7-
<p>Save the following secret to a secure location.</p>
6+
<div class="page-header"><h1>{{ _('Secret') }}</h1></div>
7+
<p>{{ _('Save the following secret to a secure location.') }}</p>
88
<div class="row">
99
<div class="col-sm-6 margin-bottom-10">
1010
<textarea class="form-control" rows="10" cols="50" id="password-text" name="password-text" readonly="readonly">{{ password }}</textarea>
1111
</div>
1212

1313
<div class="col-sm-6">
14-
<button title="Copy to clipboard" type="button" class="btn btn-primary copy-clipboard-btn"
14+
<button title="{{ _('Copy to clipboard') }}" type="button" class="btn btn-primary copy-clipboard-btn"
1515
id="copy-clipboard-btn" data-clipboard-target="#password-text"
1616
data-placement='bottom'>
1717
<i class="fa fa-clipboard"></i>
1818
</button>
1919
</div>
2020
</div>
21-
<p>The secret has now been permanently deleted from the system, and the URL will no longer work. Refresh this page to verify.</p>
21+
<p>{{ _('The secret has now been permanently deleted from the system, and the URL will no longer work. Refresh this page to verify.') }}</p>
2222
</section>
2323
</div>
2424
{% endblock %}

snappass/templates/preview.html

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
<div class="container">
55
<section>
66
<div class="page-header">
7-
<h1>Secret</h1>
7+
<h1>{{ _('Secret') }}</h1>
88
</div>
9-
<p class="lead">You can only reveal the secret once!</p>
9+
<p class="lead">{{ _('You can only reveal the secret once!') }}</p>
1010
<div class="row">
1111
<div class="col-sm-6 margin-bottom-10">
12-
<button id="revealSecret" type="button" class="btn-lg btn-primary">Reveal secret</button>
12+
<button id="revealSecret" type="button" class="btn-lg btn-primary">{{ _('Reveal secret') }}</button>
1313
</div>
1414
</div>
1515
</section>
@@ -20,4 +20,4 @@ <h1>Secret</h1>
2020
<script src="{{ config.STATIC_URL }}/clipboardjs/clipboard.min.js"></script>
2121
<script src="{{ config.STATIC_URL }}/snappass/scripts/clipboard_button.js"></script>
2222
<script src="{{ config.STATIC_URL }}/snappass/scripts/preview.js"></script>
23-
{% endblock %}
23+
{% endblock %}

snappass/templates/set_password.html

+7-7
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,27 @@
33
{% block content %}
44
<div class="container">
55
<section>
6-
<div class="page-header"><h1>Set Secret</h1></div>
6+
<div class="page-header"><h1>{{ _('Set Secret') }}</h1></div>
77
<div class="row">
88
<form role="form" id="password_create" method="post" autocomplete="off">
99
<div class="col-sm-6 margin-bottom-10">
1010
<div class="input-group">
1111
<span class="input-group-addon" id="basic-addon1"><span class="glyphicon glyphicon-lock" aria-hidden="true"></span></span>
12-
<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>
12+
<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>
1313
</div>
1414
</div>
1515

1616
<div class="col-sm-2 margin-bottom-10">
1717
<select class="form-control" name="ttl">
18-
<option value="Two Weeks">Two Weeks</option>
19-
<option value="Week" selected="selected">Week</option>
20-
<option value="Day">Day</option>
21-
<option value="Hour">Hour</option>
18+
<option value="Two Weeks">{{ _('Two Weeks') }}</option>
19+
<option value="Week" selected="selected">{{ _('Week') }}</option>
20+
<option value="Day">{{ _('Day') }}</option>
21+
<option value="Hour">{{ _('Hour') }}</option>
2222
</select>
2323
</div>
2424

2525
<div class="col-sm-4">
26-
<button type="submit" class="btn btn-primary" id="submit">Generate URL</button>
26+
<button type="submit" class="btn btn-primary" id="submit">{{ _('Generate URL') }}</button>
2727
</div>
2828
</form>
2929
</div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
# German translations for SNAPPASS.
2+
# Copyright (C) 2024 ORGANIZATION
3+
# This file is distributed under the same license as the PROJECT project.
4+
# systeembeheerder <systeembeheerder@users.noreply.github.com>, 2024.
5+
#
6+
msgid ""
7+
msgstr ""
8+
"Project-Id-Version: PROJECT VERSION\n"
9+
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
10+
"POT-Creation-Date: 2024-02-22 11:01+0100\n"
11+
"PO-Revision-Date: 2024-02-16 09:29+0100\n"
12+
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13+
"Language: de\n"
14+
"Language-Team: de <LL@li.org>\n"
15+
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
16+
"MIME-Version: 1.0\n"
17+
"Content-Type: text/plain; charset=utf-8\n"
18+
"Content-Transfer-Encoding: 8bit\n"
19+
"Generated-By: Babel 2.14.0\n"
20+
21+
#: snappass/templates/base.html:2
22+
msgid "en"
23+
msgstr "de"
24+
25+
#: snappass/templates/base.html:4
26+
msgid "Snappass - Share Secrets"
27+
msgstr "Snappass - Passwort teilen"
28+
29+
#: snappass/templates/base.html:16
30+
msgid "Share Secret"
31+
msgstr "Passwort teilen"
32+
33+
#: snappass/templates/confirm.html:6
34+
msgid "Share Secret Link"
35+
msgstr "Geheimen Link teilen"
36+
37+
#: snappass/templates/confirm.html:7
38+
msgid ""
39+
"The secret has been temporarily saved. Send the following URL to your "
40+
"intended recipient."
41+
msgstr ""
42+
"Das Geheimnis wurde vorübergehend gespeichert. Senden Sie die folgende "
43+
"URL an Ihre gewünschten Empfänger."
44+
45+
#: snappass/templates/confirm.html:14 snappass/templates/password.html:14
46+
msgid "Copy to clipboard"
47+
msgstr "In Zwischenablage kopieren"
48+
49+
#: snappass/templates/expired.html:6
50+
msgid "Secret not found"
51+
msgstr "Passwort nicht gefunden"
52+
53+
#: snappass/templates/expired.html:7
54+
msgid ""
55+
"The requested URL was not found on the server. This could be because this"
56+
" URL never contained a secret, or because it expired or was revealed "
57+
"earlier."
58+
msgstr ""
59+
"Die angeforderte URL wurde auf dem Server nicht gefunden. Dies könnte "
60+
"daran liegen, dass diesDie URL enthielt nie ein Passwort, oder weil sie "
61+
"abgelaufen ist oder offengelegt wurde "
62+
63+
#: snappass/templates/expired.html:8
64+
msgid ""
65+
"If this URL was sent to you by someone, make sure to check your spelling "
66+
"or ask the person who sent it to you to send a new secret."
67+
msgstr ""
68+
"Wenn Ihnen diese URL von jemandem gesendet wurde, überprüfen Sie "
69+
"unbedingt Ihre Rechtschreibung oder bitten Sie die Person, die es Ihnen "
70+
"geschickt hat, ein neues Passwort zu senden."
71+
72+
#: snappass/templates/password.html:6 snappass/templates/preview.html:7
73+
msgid "Secret"
74+
msgstr "Geheim"
75+
76+
#: snappass/templates/password.html:7
77+
msgid "Save the following secret to a secure location."
78+
msgstr "Speichern Sie dass folgende Passwort an einem sicheren Ort."
79+
80+
#: snappass/templates/password.html:21
81+
msgid ""
82+
"The secret has now been permanently deleted from the system, and the URL "
83+
"will no longer work. Refresh this page to verify."
84+
msgstr ""
85+
" Dass Passwort wurde nun endgültig aus dem System gelöscht, und die URL "
86+
"funktioniert nicht mehr. Aktualisieren Sie diese Seite, um dies zu "
87+
"überprüfen."
88+
89+
#: snappass/templates/preview.html:9
90+
msgid "You can only reveal the secret once!"
91+
msgstr "Du kannst das Passwort nur einmal lüften!"
92+
93+
#: snappass/templates/preview.html:12
94+
msgid "Reveal secret"
95+
msgstr "Passwort lüften"
96+
97+
#: snappass/templates/set_password.html:6
98+
msgid "Set Secret"
99+
msgstr "Geheimen Schlüssel festlegen"
100+
101+
#: snappass/templates/set_password.html:12
102+
msgid ""
103+
"SnapPass allows you to share secrets in a secure, ephemeral way. Input a "
104+
"single or multi-line secret, its expiration time, and click Generate URL."
105+
" Share the one-time use URL with your intended recipient."
106+
msgstr ""
107+
"SnapPass ermöglicht es Ihnen, Passwörter auf sichere, kurzlebige Weise zu"
108+
" teilen. Input a ein- oder mehrzeiliges Passwort, die Ablaufzeit und "
109+
"klicken Sie auf URL generieren.Teilen Sie die URL für den einmaligen "
110+
"Gebrauch mit dem beabsichtigten Empfänger."
111+
112+
#: snappass/templates/set_password.html:18
113+
msgid "Two Weeks"
114+
msgstr "Zwei Wochen"
115+
116+
#: snappass/templates/set_password.html:19
117+
msgid "Week"
118+
msgstr "Woche"
119+
120+
#: snappass/templates/set_password.html:20
121+
msgid "Day"
122+
msgstr "Tag"
123+
124+
#: snappass/templates/set_password.html:21
125+
msgid "Hour"
126+
msgstr "Stunde"
127+
128+
#: snappass/templates/set_password.html:26
129+
msgid "Generate URL"
130+
msgstr "URL generieren"
131+

0 commit comments

Comments
 (0)