1
0
Fork 0

Add translations on unseal page.

This commit is contained in:
Kitteh 2021-04-19 19:45:51 +01:00
parent 65d2961cb0
commit a36aa172ab
5 changed files with 21 additions and 22 deletions

View file

@ -172,7 +172,8 @@ function onLoad() {
document.addEventListener('DOMContentLoaded', function () {
i18next.init({
lng: 'en',
lng: localStorage.getItem("language") || "en",
fallbackLng: 'en',
debug: true,
resources: {
en: { translation: translation_en },

View file

@ -74,19 +74,6 @@ export class HomePage extends Page {
const navList = makeElement({ tag: "ul", class: ["uk-nav", "uk-nav-default", "uk-margin-top"] });
pageContent.appendChild(navList);
navList.appendChild(makeElement({
tag: "li",
children: makeElement({
tag: "a",
text: "Cubbyhole - /cubbyhole",
onclick: _ => {
pageState.currentBaseMount = "/cubbyhole";
pageState.currentMountType = "cubbyhole";
changePage("KEY_VALUE_VIEW");
}
})
}));
let mounts = await getMounts();
// sort it by secretPath so it's in alphabetical order consistantly.
const mountsMap = new Map(Object.entries(mounts).sort());
@ -95,7 +82,7 @@ export class HomePage extends Page {
if (typeof mount != 'object') return;
if (mount == null) return;
if (!("type" in mount)) return;
if (!(["kv", "totp", "transit"].includes(mount.type))) return;
if (!(["kv", "totp", "transit", "cubbyhole"].includes(mount.type))) return;
let mountType = mount.type == "kv" ? "kv-v" + String(mount.options.version) : mount.type;
@ -110,6 +97,9 @@ export class HomePage extends Page {
} else if (mount.type == "transit"){
linkText = `Transit - ${baseMount}`;
linkPage = "TRANSIT_VIEW";
} else if (mount.type == "cubbyhole"){
linkText = `Cubbyhole - ${baseMount}`;
linkPage = "KEY_VALUE_VIEW";
}
navList.appendChild(makeElement({

View file

@ -3,6 +3,7 @@ import { submitUnsealKey, getSealStatus } from "../api.js";
import { setPageContent, setErrorText, changePage } from "../pageUtils.js";
import { makeElement } from "../htmlUtils.js";
import { MarginInline } from "../elements/MarginInline.js";
import i18next from 'i18next';
export class UnsealPage extends Page {
constructor() {
@ -18,14 +19,14 @@ export class UnsealPage extends Page {
attributes: {
required: true,
type: "password",
placeholder: "Key",
placeholder: i18next.t("key_input_placeholder"),
name: "key"
}
})),
MarginInline(makeElement({
tag: "button",
class: ["uk-button", "uk-button-primary"],
text: "Submit Key"
text: i18next.t("submit_key_btn")
})),
]
});
@ -37,7 +38,7 @@ export class UnsealPage extends Page {
});
this.unsealProgressText = makeElement({
tag: "p",
text: "Keys: 0/0",
text: i18next.t("unseal_keys_progress", { progress: "0", keys_needed: "0" }),
});
setPageContent(makeElement({
@ -63,7 +64,10 @@ export class UnsealPage extends Page {
let progress = data.progress;
let keysNeeded = data.t;
let text = this.unsealProgressText;
text.innerText = `Keys: ${progress}/${keysNeeded}`;
text.innerText = i18next.t("unseal_keys_progress", {
progress: String(progress),
keys_needed: String(keysNeeded)
});
let progressBar = this.unsealProgress;
progressBar.value = progress;
progressBar.max = keysNeeded;
@ -85,6 +89,6 @@ export class UnsealPage extends Page {
});
}
get name() {
return "Unseal";
return i18next.t("unseal_vault_text");
}
}

View file

@ -18,6 +18,11 @@ module.exports = {
"vaulturl_text": "Vault URL: {{text}}",
"password_generator_btn": "Password Generator",
"your_token_expires_in": "Your token expires in {{date, until_date}}"
"your_token_expires_in": "Your token expires in {{date, until_date}}",
"unseal_vault_text": "Unseal the Vault",
"submit_key_btn": "Submit Key",
"key_input_placeholder": "Key",
"unseal_keys_progress": "Keys: {{progress}}/{{keys_needed}}"
}

View file

@ -19,5 +19,4 @@ module.exports = {
"vaulturl_text": "Vault URL: {{text}}",
"password_generator_btn": "Wachtwoordgenerator",
"your_token_expires_in": "Uw token vervalt in {{date, until_date}}"
}