Skip to content

Commit 68c9189

Browse files
committed
More translations
1 parent f3b67e0 commit 68c9189

File tree

10 files changed

+782
-647
lines changed

10 files changed

+782
-647
lines changed

etsd/keys/forms.py

+4-7
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from django import forms
33
from django.conf import settings
44
from django.utils.translation import ugettext as _
5+
from django.utils.translation import ugettext_lazy as __
56
import gnupg
67
from .util import check_signatures
78

@@ -57,13 +58,9 @@ def __init__(self, *args, **kwargs):
5758

5859

5960
class LoadPrivateKeyForm(forms.Form):
60-
fingerprint = forms.CharField(
61-
max_length=128,
62-
)
63-
user_id = forms.CharField(
64-
max_length=512,
65-
)
66-
creation_time = forms.CharField(max_length=512)
61+
fingerprint = forms.CharField(max_length=128, label=__("Fingerprint"))
62+
user_id = forms.CharField(max_length=512, label=__("User id"))
63+
creation_time = forms.CharField(max_length=512, label=__("Creation time"))
6764

6865
def __init__(self, *args, **kwargs):
6966
super().__init__(*args, **kwargs)

etsd/keys/templates/keys/load_private_key.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
{% csrf_token %}
6565
<div class="card">
6666
<div class="card-body">
67-
<h5 class="card-title">Private key information</h5>
67+
<h5 class="card-title">{% trans "Private key information" %}</h5>
6868
<div class='row'>
6969
<div class='col'>
7070
{{ form.fingerprint|as_crispy_field }}

etsd/msgs/static/message_detail.js

+107
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
const messageData = JSON.parse(document.getElementById('message-data').textContent);
2+
const cipherData = JSON.parse(document.getElementById('authority-cipher-data').textContent);
3+
4+
if(privateKeyFingerprint) {
5+
gtools.loadPrivateKeyLocal().then(
6+
privateKey=>{
7+
console.log("Private key loaded!")
8+
window.privateKey=privateKey
9+
}
10+
)
11+
}
12+
13+
14+
const decryptAndDownload = (cipher_id, data_ext) => {
15+
console.log("OK DOWNLOAD ", cipher_id, data_ext)
16+
const url = `${cipherDataFileUrl}${cipher_id}/`
17+
// Download the cipher
18+
$.ajax({
19+
url,
20+
success: data => {
21+
// And decrypt it using the loaded private key
22+
gtools.decrypt(privateKey, data).then(
23+
decrypted => {
24+
// After it's been decrypted just download it with the downloadBlob
25+
gtools.downloadBlob(new Blob([decrypted]), cipher_id+'.'+data_ext)
26+
}
27+
,
28+
reason => console.log(reason) // No error handling for now
29+
).catch(
30+
err => console.log(err) // No error handling for now
31+
)
32+
},
33+
cache: false
34+
})
35+
return false
36+
}
37+
38+
const deleteCipherData = (cipher_id) => {
39+
const csrftoken = document.querySelector('[name=csrfmiddlewaretoken]').value;
40+
41+
const cb = () => {
42+
const url = `${cipherDataDeleteUrl}${cipher_id}/`
43+
$.ajax({
44+
url,
45+
method: 'POST',
46+
headers: {'X-CSRFToken': csrftoken},
47+
success: data => {
48+
location.reload();
49+
},
50+
error: function (xhr, ajaxOptions, thrownError) {
51+
if(xhr.status == 403) {
52+
bootstrap5Alert({
53+
'message': gettext("You cannot delete this file. Please make sure that you have read all the message files first."),
54+
'title': gettext("ERROR")
55+
})
56+
}
57+
},
58+
cache: false
59+
})
60+
}
61+
bootstrap5Alert({
62+
'message': gettext("Are you sure you want to delete this file?"),
63+
'title': gettext("Confirm"),
64+
'actionText': gettext("Delete"),
65+
'cb': cb
66+
})
67+
return false
68+
}
69+
70+
$(function() {
71+
if(messageData.length > 0) {
72+
const cipherDataContent = messageData.map(md => {
73+
let cd = cipherData.find(cd => cd.data_id == md.data_id)
74+
75+
return `<tr>
76+
<td>${md.number}</td>
77+
<td>${md.ext}</td>
78+
<td>${cd?cd.authority_name:"-"}</td>
79+
<td>${
80+
cd?
81+
(cd.fingerprint==privateKeyFingerprint
82+
?`<button class='btn btn-warning btn-sm' onclick='return decryptAndDownload(${cd.id}, "${cd.ext}")'>
83+
${gettext('Decrypt and download')}
84+
</button>`
85+
:`<span class='text-danger'>
86+
${gettext('Not possible to decrypt. Please make sure you have loaded the proper private key')}
87+
</span>`
88+
):`<span class='text-danger'>${gettext('Cipher data not available')}</span>`
89+
}</td>
90+
<td>
91+
${cd?`<a onclick='return deleteCipherData(${cd.id})' class='btn btn-danger' href='#'>${gettext('Delete')}</a>`:'-'}
92+
</td>
93+
</tr>`
94+
}).join('')
95+
96+
$('#cipher-data-container').html(cipherDataContent)
97+
}
98+
99+
confirmFormAction({
100+
sel: '#sendForm',
101+
message: gettext('Are you sure you want to send the message?'),
102+
title: gettext('Send message'),
103+
color: 'success'
104+
})
105+
confirmDelete('#deleteForm')
106+
107+
})

etsd/msgs/templates/msgs/message_detail.html

+2-111
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{% extends "site_base.html" %}
2-
{% load i18n %}
2+
{% load i18n static %}
33
{% load rules_light_tags %}
44
{% block head_title %}{% trans "Message detail" %}{% endblock %}
55
{% block page_title %}{% trans "Message detail" %}{% endblock %}
@@ -154,114 +154,5 @@ <h5>{% trans "Data" %}</h5>
154154
{% endblock %}
155155

156156
{% block extra_script %}
157-
<script>
158-
const messageData = JSON.parse(document.getElementById('message-data').textContent);
159-
const cipherData = JSON.parse(document.getElementById('authority-cipher-data').textContent);
160-
161-
if(privateKeyFingerprint) {
162-
gtools.loadPrivateKeyLocal().then(
163-
privateKey=>{
164-
console.log("Private key loaded!")
165-
window.privateKey=privateKey
166-
}
167-
)
168-
}
169-
170-
171-
const decryptAndDownload = (cipher_id, data_ext) => {
172-
console.log("OK DOWNLOAD ", cipher_id, data_ext)
173-
const url = `${cipherDataFileUrl}${cipher_id}/`
174-
// Download the cipher
175-
$.ajax({
176-
url,
177-
success: data => {
178-
// And decrypt it using the loaded private key
179-
gtools.decrypt(privateKey, data).then(
180-
decrypted => {
181-
// After it's been decrypted just download it with the downloadBlob
182-
gtools.downloadBlob(new Blob([decrypted]), cipher_id+'.'+data_ext)
183-
}
184-
,
185-
reason => console.log(reason) // No error handling for now
186-
).catch(
187-
err => console.log(err) // No error handling for now
188-
)
189-
},
190-
cache: false
191-
})
192-
return false
193-
}
194-
195-
const deleteCipherData = (cipher_id) => {
196-
const csrftoken = document.querySelector('[name=csrfmiddlewaretoken]').value;
197-
198-
const cb = () => {
199-
const url = `${cipherDataDeleteUrl}${cipher_id}/`
200-
$.ajax({
201-
url,
202-
method: 'POST',
203-
headers: {'X-CSRFToken': csrftoken},
204-
success: data => {
205-
location.reload();
206-
},
207-
error: function (xhr, ajaxOptions, thrownError) {
208-
if(xhr.status == 403) {
209-
bootstrap5Alert({
210-
'message': gettext("You cannot delete this file. Please make sure that you have read all the message files first."),
211-
'title': gettext("ERROR")
212-
})
213-
}
214-
},
215-
cache: false
216-
})
217-
}
218-
bootstrap5Alert({
219-
'message': gettext("Are you sure you want to delete this file?"),
220-
'title': gettext("Confirm"),
221-
'actionText': gettext("Delete"),
222-
'cb': cb
223-
})
224-
return false
225-
}
226-
227-
$(function() {
228-
if(messageData.length > 0) {
229-
const cipherDataContent = messageData.map(md => {
230-
let cd = cipherData.find(cd => cd.data_id == md.data_id)
231-
232-
return `<tr>
233-
<td>${md.number}</td>
234-
<td>${md.ext}</td>
235-
<td>${cd?cd.authority_name:"-"}</td>
236-
<td>${
237-
cd?
238-
(cd.fingerprint==privateKeyFingerprint
239-
?`<button class='btn btn-warning btn-sm' onclick='return decryptAndDownload(${cd.id}, "${cd.ext}")'>
240-
${gettext('Decrypt and download')}
241-
</button>`
242-
:`<span class='text-danger'>
243-
${gettext('Not possible to decrypt. Please make sure you have loaded the proper private key')}
244-
</span>`
245-
):`<span class='text-danger'>${gettext('Cipher data not available')}</span>`
246-
}</td>
247-
<td>
248-
${cd?`<a onclick='return deleteCipherData(${cd.id})' class='btn btn-danger' href='#'>${gettext('Delete')}</a>`:'-'}
249-
</td>
250-
</tr>`
251-
}).join('')
252-
253-
$('#cipher-data-container').html(cipherDataContent)
254-
}
255-
256-
confirmFormAction({
257-
sel: '#sendForm',
258-
message: gettext('Are you sure you want to send the message?'),
259-
title: gettext('Send message'),
260-
color: 'success'
261-
})
262-
confirmDelete('#deleteForm')
263-
264-
})
265-
</script>
266-
157+
<script src='{% static "message_detail.js"' %}'></script>
267158
{% endblock %}

locale/el/LC_MESSAGES/django.mo

1.8 KB
Binary file not shown.

0 commit comments

Comments
 (0)