Add translations on unseal page.
This commit is contained in:
parent
65d2961cb0
commit
a36aa172ab
|
@ -172,7 +172,8 @@ function onLoad() {
|
||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', function () {
|
document.addEventListener('DOMContentLoaded', function () {
|
||||||
i18next.init({
|
i18next.init({
|
||||||
lng: 'en',
|
lng: localStorage.getItem("language") || "en",
|
||||||
|
fallbackLng: 'en',
|
||||||
debug: true,
|
debug: true,
|
||||||
resources: {
|
resources: {
|
||||||
en: { translation: translation_en },
|
en: { translation: translation_en },
|
||||||
|
|
|
@ -74,19 +74,6 @@ export class HomePage extends Page {
|
||||||
const navList = makeElement({ tag: "ul", class: ["uk-nav", "uk-nav-default", "uk-margin-top"] });
|
const navList = makeElement({ tag: "ul", class: ["uk-nav", "uk-nav-default", "uk-margin-top"] });
|
||||||
pageContent.appendChild(navList);
|
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();
|
let mounts = await getMounts();
|
||||||
// sort it by secretPath so it's in alphabetical order consistantly.
|
// sort it by secretPath so it's in alphabetical order consistantly.
|
||||||
const mountsMap = new Map(Object.entries(mounts).sort());
|
const mountsMap = new Map(Object.entries(mounts).sort());
|
||||||
|
@ -95,7 +82,7 @@ export class HomePage extends Page {
|
||||||
if (typeof mount != 'object') return;
|
if (typeof mount != 'object') return;
|
||||||
if (mount == null) return;
|
if (mount == null) return;
|
||||||
if (!("type" in mount)) 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;
|
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"){
|
} else if (mount.type == "transit"){
|
||||||
linkText = `Transit - ${baseMount}`;
|
linkText = `Transit - ${baseMount}`;
|
||||||
linkPage = "TRANSIT_VIEW";
|
linkPage = "TRANSIT_VIEW";
|
||||||
|
} else if (mount.type == "cubbyhole"){
|
||||||
|
linkText = `Cubbyhole - ${baseMount}`;
|
||||||
|
linkPage = "KEY_VALUE_VIEW";
|
||||||
}
|
}
|
||||||
|
|
||||||
navList.appendChild(makeElement({
|
navList.appendChild(makeElement({
|
||||||
|
|
|
@ -3,6 +3,7 @@ import { submitUnsealKey, getSealStatus } from "../api.js";
|
||||||
import { setPageContent, setErrorText, changePage } from "../pageUtils.js";
|
import { setPageContent, setErrorText, changePage } from "../pageUtils.js";
|
||||||
import { makeElement } from "../htmlUtils.js";
|
import { makeElement } from "../htmlUtils.js";
|
||||||
import { MarginInline } from "../elements/MarginInline.js";
|
import { MarginInline } from "../elements/MarginInline.js";
|
||||||
|
import i18next from 'i18next';
|
||||||
|
|
||||||
export class UnsealPage extends Page {
|
export class UnsealPage extends Page {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
@ -18,14 +19,14 @@ export class UnsealPage extends Page {
|
||||||
attributes: {
|
attributes: {
|
||||||
required: true,
|
required: true,
|
||||||
type: "password",
|
type: "password",
|
||||||
placeholder: "Key",
|
placeholder: i18next.t("key_input_placeholder"),
|
||||||
name: "key"
|
name: "key"
|
||||||
}
|
}
|
||||||
})),
|
})),
|
||||||
MarginInline(makeElement({
|
MarginInline(makeElement({
|
||||||
tag: "button",
|
tag: "button",
|
||||||
class: ["uk-button", "uk-button-primary"],
|
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({
|
this.unsealProgressText = makeElement({
|
||||||
tag: "p",
|
tag: "p",
|
||||||
text: "Keys: 0/0",
|
text: i18next.t("unseal_keys_progress", { progress: "0", keys_needed: "0" }),
|
||||||
});
|
});
|
||||||
|
|
||||||
setPageContent(makeElement({
|
setPageContent(makeElement({
|
||||||
|
@ -63,7 +64,10 @@ export class UnsealPage extends Page {
|
||||||
let progress = data.progress;
|
let progress = data.progress;
|
||||||
let keysNeeded = data.t;
|
let keysNeeded = data.t;
|
||||||
let text = this.unsealProgressText;
|
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;
|
let progressBar = this.unsealProgress;
|
||||||
progressBar.value = progress;
|
progressBar.value = progress;
|
||||||
progressBar.max = keysNeeded;
|
progressBar.max = keysNeeded;
|
||||||
|
@ -85,6 +89,6 @@ export class UnsealPage extends Page {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
get name() {
|
get name() {
|
||||||
return "Unseal";
|
return i18next.t("unseal_vault_text");
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -18,6 +18,11 @@ module.exports = {
|
||||||
|
|
||||||
"vaulturl_text": "Vault URL: {{text}}",
|
"vaulturl_text": "Vault URL: {{text}}",
|
||||||
"password_generator_btn": "Password Generator",
|
"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}}"
|
||||||
|
|
||||||
}
|
}
|
|
@ -19,5 +19,4 @@ module.exports = {
|
||||||
"vaulturl_text": "Vault URL: {{text}}",
|
"vaulturl_text": "Vault URL: {{text}}",
|
||||||
"password_generator_btn": "Wachtwoordgenerator",
|
"password_generator_btn": "Wachtwoordgenerator",
|
||||||
"your_token_expires_in": "Uw token vervalt in {{date, until_date}}"
|
"your_token_expires_in": "Uw token vervalt in {{date, until_date}}"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue