diff --git a/src/main.js b/src/main.js index e6ffb54..90a9d37 100644 --- a/src/main.js +++ b/src/main.js @@ -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 }, diff --git a/src/pages/Home.js b/src/pages/Home.js index c7a4941..51526f8 100644 --- a/src/pages/Home.js +++ b/src/pages/Home.js @@ -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({ diff --git a/src/pages/Unseal.js b/src/pages/Unseal.js index 99bfb0f..e2dd28a 100644 --- a/src/pages/Unseal.js +++ b/src/pages/Unseal.js @@ -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"); } } \ No newline at end of file diff --git a/src/translations/en.js b/src/translations/en.js index f23645d..1827091 100644 --- a/src/translations/en.js +++ b/src/translations/en.js @@ -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}}" } \ No newline at end of file diff --git a/src/translations/nl.js b/src/translations/nl.js index bf6b33f..78a1411 100644 --- a/src/translations/nl.js +++ b/src/translations/nl.js @@ -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}}" - }