1
0
Fork 0

Add translations on TransitDecryptPage and TransitEncryptPage

This commit is contained in:
Kitteh 2021-04-29 11:03:24 +01:00
parent 76d58d1850
commit 4fefad2c16
3 changed files with 28 additions and 12 deletions

View file

@ -5,6 +5,7 @@ import { makeElement } from "../../htmlUtils.js";
import { Margin } from "../../elements/Margin.js"; import { Margin } from "../../elements/Margin.js";
import { CopyableModal } from "../../elements/CopyableModal.js"; import { CopyableModal } from "../../elements/CopyableModal.js";
import UIkit from 'uikit/dist/js/uikit.min.js'; import UIkit from 'uikit/dist/js/uikit.min.js';
import i18next from "i18next";
export class TransitDecryptPage extends Page { export class TransitDecryptPage extends Page {
@ -26,7 +27,7 @@ export class TransitDecryptPage extends Page {
tag: "textarea", tag: "textarea",
class: ["uk-textarea", "uk-form-width-medium"], class: ["uk-textarea", "uk-form-width-medium"],
attributes: { attributes: {
placeholder: "Ciphertext", placeholder: i18next.t("transit_decrypt_input_placeholder"),
name: "ciphertext", name: "ciphertext",
} }
})), })),
@ -34,7 +35,7 @@ export class TransitDecryptPage extends Page {
makeElement({ makeElement({
tag: "div", tag: "div",
class: "uk-form-label", class: "uk-form-label",
text: "Should the plaintext be base64 decoded?", text: i18next.t("transit_decrypt_decode_checkbox"),
}), }),
makeElement({ makeElement({
tag: "div", tag: "div",
@ -56,7 +57,7 @@ export class TransitDecryptPage extends Page {
makeElement({ makeElement({
tag: "button", tag: "button",
class: ["uk-button", "uk-button-primary"], class: ["uk-button", "uk-button-primary"],
text: "Decrypt", text: i18next.t("transit_decrypt_decrypt_btn"),
attributes: { attributes: {
type: "submit", type: "submit",
} }
@ -78,7 +79,7 @@ export class TransitDecryptPage extends Page {
if (formData.get("decodeBase64Checkbox") == "on") { if (formData.get("decodeBase64Checkbox") == "on") {
plaintext = atob(plaintext); plaintext = atob(plaintext);
} }
let modal = CopyableModal("Decryption Result", plaintext); let modal = CopyableModal(i18next.t("transit_decrypt_decryption_result_modal_title"), plaintext);
pageContent.appendChild(modal); pageContent.appendChild(modal);
UIkit.modal(modal).show(); UIkit.modal(modal).show();
}).catch(e => { }).catch(e => {
@ -87,10 +88,10 @@ export class TransitDecryptPage extends Page {
} }
get titleSuffix() { get titleSuffix() {
return " (decrypt)"; return i18next.t("transit_decrypt_suffix");
} }
get name() { get name() {
return "Transit Decrypt"; return i18next.t("transit_decrypt_title");
} }
} }

View file

@ -5,6 +5,7 @@ import { makeElement } from "../../htmlUtils.js";
import { Margin } from "../../elements/Margin.js"; import { Margin } from "../../elements/Margin.js";
import { CopyableModal } from "../../elements/CopyableModal.js"; import { CopyableModal } from "../../elements/CopyableModal.js";
import UIkit from 'uikit/dist/js/uikit.min.js'; import UIkit from 'uikit/dist/js/uikit.min.js';
import i18next from "i18next";
export class TransitEncryptPage extends Page { export class TransitEncryptPage extends Page {
@ -26,7 +27,7 @@ export class TransitEncryptPage extends Page {
tag: "textarea", tag: "textarea",
class: ["uk-textarea", "uk-form-width-medium"], class: ["uk-textarea", "uk-form-width-medium"],
attributes: { attributes: {
placeholder: "Plaintext or base64", placeholder: i18next.t("transit_encrypt_input_placeholder"),
name: "plaintext", name: "plaintext",
} }
})), })),
@ -34,7 +35,7 @@ export class TransitEncryptPage extends Page {
makeElement({ makeElement({
tag: "div", tag: "div",
class: "uk-form-label", class: "uk-form-label",
text: "Is the data already encoded in base64?", text: i18next.t("transit_encrypt_already_encoded_checkbox"),
}), }),
makeElement({ makeElement({
tag: "div", tag: "div",
@ -56,7 +57,7 @@ export class TransitEncryptPage extends Page {
makeElement({ makeElement({
tag: "button", tag: "button",
class: ["uk-button", "uk-button-primary"], class: ["uk-button", "uk-button-primary"],
text: "Encrypt", text: i18next.t("transit_encrypt_encrypt_btn"),
attributes: { attributes: {
type: "submit", type: "submit",
} }
@ -77,7 +78,7 @@ export class TransitEncryptPage extends Page {
formData.get("base64Checkbox") == "on" ? formData.get("plaintext") : btoa(formData.get("plaintext")); formData.get("base64Checkbox") == "on" ? formData.get("plaintext") : btoa(formData.get("plaintext"));
transitEncrypt(pageState.currentBaseMount, pageState.currentSecret, encodedData).then(res => { transitEncrypt(pageState.currentBaseMount, pageState.currentSecret, encodedData).then(res => {
console.log(res); console.log(res);
let modal = CopyableModal("Encryption Result", res.ciphertext); let modal = CopyableModal(i18next.t("transit_encrypt_encryption_result_modal_title"), res.ciphertext);
pageContent.appendChild(modal); pageContent.appendChild(modal);
UIkit.modal(modal).show(); UIkit.modal(modal).show();
}).catch(e => { }).catch(e => {
@ -86,10 +87,10 @@ export class TransitEncryptPage extends Page {
} }
get titleSuffix() { get titleSuffix() {
return " (encrypt)"; return i18next.t("transit_encrypt_suffix");
} }
get name() { get name() {
return "Transit Encrypt"; return i18next.t("transit_encrypt_title");
} }
} }

View file

@ -124,5 +124,19 @@ module.exports = {
"transit_view_decrypt_description": "Decrypt some cyphertext.", "transit_view_decrypt_description": "Decrypt some cyphertext.",
"transit_view_decrypt_icon_text": "Decryption Icon", "transit_view_decrypt_icon_text": "Decryption Icon",
// Transit Encrypt Page
"transit_encrypt_title": "Transit Encrypt",
"transit_encrypt_suffix": " (encrypt)",
"transit_encrypt_input_placeholder": "Plaintext or base64",
"transit_encrypt_already_encoded_checkbox": "Is the data already encoded in base64?",
"transit_encrypt_encrypt_btn": "Encrypt",
"transit_encrypt_encryption_result_modal_title": "Encryption Result",
// Transit decrypt Page
"transit_decrypt_title": "Transit Decrypt",
"transit_decrypt_suffix": " (decrypt)",
"transit_decrypt_input_placeholder": "Cyphertext",
"transit_decrypt_decode_checkbox": "Should the plaintext be base64 decoded?",
"transit_decrypt_decrypt_btn": "Decrypt",
"transit_decrypt_decryption_result_modal_title": "Decryption Result",
} }