diff --git a/src/main.js b/src/main.js index 19bf3fc..2f2f206 100644 --- a/src/main.js +++ b/src/main.js @@ -74,6 +74,14 @@ import translation_nl from './translations/nl.js' import formatDistance from 'date-fns/formatDistance'; +/*import "en-GB" as date_locale_en from 'date-fns/locale' + +function getDateLocale() { + let locales = { + en: + } +}*/ + // Globals diff --git a/src/pages/Login.js b/src/pages/Login.js index 4388de6..01ab679 100644 --- a/src/pages/Login.js +++ b/src/pages/Login.js @@ -4,6 +4,7 @@ import { setPageContent, setErrorText, changePage } from "../pageUtils.js"; import { makeElement } from "../htmlUtils.js"; import { Margin } from "../elements/Margin.js"; import { MarginInline } from "../elements/MarginInline.js"; +import i18next from 'i18next'; export class LoginPage extends Page { constructor() { @@ -19,14 +20,14 @@ export class LoginPage extends Page { attributes: { required: true, type: "password", - placeholder: "Token", + placeholder: i18next.t("token_input"), name: "token" } })), MarginInline(makeElement({ tag: "button", class: ["uk-button", "uk-button-primary"], - text: "Log In", + text: i18next.t("log_in_btn"), attributes: { type: "submit" } @@ -44,7 +45,7 @@ export class LoginPage extends Page { attributes: { required: true, type: "text", - placeholder: "Username", + placeholder: i18next.t("username_input"), name: "username" } })), @@ -55,14 +56,14 @@ export class LoginPage extends Page { attributes: { required: true, type: "password", - placeholder: "Password", + placeholder: i18next.t("password_input"), name: "password" } })), MarginInline(makeElement({ tag: "button", class: ["uk-button", "uk-button-primary"], - text: "Log In", + text: i18next.t("log_in_btn"), attributes: { type: "submit" } @@ -83,14 +84,14 @@ export class LoginPage extends Page { id: "tokenInput", children: makeElement({ tag: "a", - text: "Token" + text: i18next.t("log_in_with_token") }) }), makeElement({ tag: "li", children: makeElement({ tag: "a", - text: "Username" + text: i18next.t("log_in_with_username") }) }) ] @@ -144,6 +145,6 @@ export class LoginPage extends Page { } get name() { - return "Login"; + return i18next.t("log_in_title"); } } \ No newline at end of file diff --git a/src/pages/PwGen.js b/src/pages/PwGen.js index 54e8222..efd9f92 100644 --- a/src/pages/PwGen.js +++ b/src/pages/PwGen.js @@ -1,8 +1,9 @@ import { Page } from "../types/Page.js"; import { setPageContent } from "../pageUtils.js"; import { makeElement } from "../htmlUtils.js"; - import { CopyableInputBox } from "../elements/CopyableInputBox.js"; +import i18next from 'i18next'; + function random() { const { @@ -40,7 +41,7 @@ export class PwGenPage extends Page { inputBox, makeElement({ tag: "button", - text: "Gen New Password", + text: i18next.t("gen_password_btn"), class: ["uk-button", "uk-button-primary", "uk-margin-bottom"], onclick: () => { inputBox.setText(genPw(24)); @@ -51,6 +52,6 @@ export class PwGenPage extends Page { } get name() { - return "Password Generator"; + return i18next.t("password_generator_title"); } } \ No newline at end of file diff --git a/src/pages/SetLanguage.js b/src/pages/SetLanguage.js index 990a003..d78cca5 100644 --- a/src/pages/SetLanguage.js +++ b/src/pages/SetLanguage.js @@ -25,7 +25,7 @@ export class SetLanguagePage extends Page { return makeElement({ tag: "option", text: i18next.getFixedT(languageID, null)("language_name"), - attributes: {value: languageID} + attributes: { value: languageID } }) }) }) @@ -52,8 +52,8 @@ export class SetLanguagePage extends Page { let language = formData.get("language"); localStorage.setItem('language', language); i18next.changeLanguage(language).then((t) => { - changePage("HOME", false); - location.reload(); + changePage("HOME", false); + location.reload(); }); }); } diff --git a/src/translations/en.js b/src/translations/en.js index dbcaff1..c5c181b 100644 --- a/src/translations/en.js +++ b/src/translations/en.js @@ -28,4 +28,17 @@ module.exports = { "set_language_title": "Set Language", "set_language_btn": "Set Language", + + "password_generator_title": "Password Generator", + "gen_password_btn": "Generate Password", + + "log_in_title": "Login", + "log_in_with_token": "Token", + "log_in_with_username": "Username", + "token_input": "Token", + "username_input": "Username", + "password_input": "Password", + "log_in_btn": "Login" + + } \ No newline at end of file