From 368feeb76bc0ec0c46cec01e760430b63450090d Mon Sep 17 00:00:00 2001 From: Kitteh Date: Tue, 20 Apr 2021 23:02:18 +0100 Subject: [PATCH] Add translations to KeyValueSecretsEdit and fix build. --- src/pages/KeyValue/KeyValueSecretsEdit.js | 15 ++++++++++----- src/pages/index.js | 2 +- src/translations/en.js | 8 +++++++- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/pages/KeyValue/KeyValueSecretsEdit.js b/src/pages/KeyValue/KeyValueSecretsEdit.js index 26938a3..0309b27 100644 --- a/src/pages/KeyValue/KeyValueSecretsEdit.js +++ b/src/pages/KeyValue/KeyValueSecretsEdit.js @@ -4,6 +4,8 @@ import { verifyJSONString } from "../../utils.js"; import { setPageContent, setTitleElement, setErrorText, changePage } from "../../pageUtils.js"; import { makeElement } from "../../htmlUtils.js"; import { CodeJar } from "codejar"; +import i18next from 'i18next'; + export class KeyValueSecretEditPage extends Page { constructor() { @@ -14,7 +16,10 @@ export class KeyValueSecretEditPage extends Page { } render() { setTitleElement(pageState); - let loadingText = makeElement({ tag: "p", text: "Loading.." }); + let loadingText = makeElement({ + tag: "p", + text: i18next.t("kv_sec_edit_loading") + }); let editor = makeElement({ tag: "div", class: ["editor", "language-json"] @@ -22,7 +27,7 @@ export class KeyValueSecretEditPage extends Page { let saveButton = makeElement({ tag: "button", class: ["uk-button", "uk-button-primary"], - text: "Save" + text: i18next.t("kv_sec_edit_btn") }); setPageContent(makeElement({ tag: "div", @@ -46,7 +51,7 @@ export class KeyValueSecretEditPage extends Page { jar.updateCode(secretsJSON); saveButton.onclick = function () { if (!verifyJSONString(jar.toString())) { - setErrorText("Invalid JSON"); + setErrorText(i18next.t("kv_sec_edit_invalid_json_err")); return; } createOrUpdateSecret( @@ -65,10 +70,10 @@ export class KeyValueSecretEditPage extends Page { } get titleSuffix() { - return " (edit)"; + return i18next.t("kv_sec_edit_suffix"); } get name() { - return "K/V Secrets Edit"; + return i18next.t("kv_sec_edit_title"); } } \ No newline at end of file diff --git a/src/pages/index.js b/src/pages/index.js index 68aaa11..bfbcd27 100644 --- a/src/pages/index.js +++ b/src/pages/index.js @@ -8,7 +8,7 @@ export { SetLanguagePage } from "./SetLanguage.js"; export { TOTPViewPage } from "./TOTP/TOTPView.js"; export { NewTOTPPage } from "./TOTP/NewTOTP.js"; export { KeyValueViewPage } from "./KeyValue/KeyValueView.js"; -export { KeyValueSecretPage } from "./KeyValue/KeyValueSecrets.js"; +export { KeyValueSecretPage } from "./KeyValue/KeyValueSecret.js"; export { KeyValueVersionsPage } from "./KeyValue/KeyValueVersions.js"; export { KeyValueNewPage } from "./KeyValue/KeyValueNew.js"; export { KeyValueDeletePage } from "./KeyValue/KeyValueDelete.js"; diff --git a/src/translations/en.js b/src/translations/en.js index d88467f..c5ae16e 100644 --- a/src/translations/en.js +++ b/src/translations/en.js @@ -67,7 +67,13 @@ module.exports = { "kv_secret_delete_all_btn": "Delete All Versions", "kv_secret_delete_version_btn": "Delete Version {{ version }}", "kv_secret_edit_btn": "Edit", - "kv_secret_versions_btn": "Versions" + "kv_secret_versions_btn": "Versions", + // Key Value Secret Editor Page + "kv_sec_edit_title": "K/V Edit", + "kv_sec_edit_btn": "Edit", + "kv_sec_edit_loading": "Loading Editor..", + "kv_sec_edit_invalid_json_err": "Invalid JSON", + "kv_sec_edit_suffix": " (edit)", } \ No newline at end of file