Add en translations for Password Generator and Login pages.
This commit is contained in:
parent
71eda16ec3
commit
cc61c26264
|
@ -74,6 +74,14 @@ import translation_nl from './translations/nl.js'
|
||||||
import formatDistance from 'date-fns/formatDistance';
|
import formatDistance from 'date-fns/formatDistance';
|
||||||
|
|
||||||
|
|
||||||
|
/*import "en-GB" as date_locale_en from 'date-fns/locale'
|
||||||
|
|
||||||
|
function getDateLocale() {
|
||||||
|
let locales = {
|
||||||
|
en:
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
|
|
||||||
// Globals
|
// Globals
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ import { setPageContent, setErrorText, changePage } from "../pageUtils.js";
|
||||||
import { makeElement } from "../htmlUtils.js";
|
import { makeElement } from "../htmlUtils.js";
|
||||||
import { Margin } from "../elements/Margin.js";
|
import { Margin } from "../elements/Margin.js";
|
||||||
import { MarginInline } from "../elements/MarginInline.js";
|
import { MarginInline } from "../elements/MarginInline.js";
|
||||||
|
import i18next from 'i18next';
|
||||||
|
|
||||||
export class LoginPage extends Page {
|
export class LoginPage extends Page {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
@ -19,14 +20,14 @@ export class LoginPage extends Page {
|
||||||
attributes: {
|
attributes: {
|
||||||
required: true,
|
required: true,
|
||||||
type: "password",
|
type: "password",
|
||||||
placeholder: "Token",
|
placeholder: i18next.t("token_input"),
|
||||||
name: "token"
|
name: "token"
|
||||||
}
|
}
|
||||||
})),
|
})),
|
||||||
MarginInline(makeElement({
|
MarginInline(makeElement({
|
||||||
tag: "button",
|
tag: "button",
|
||||||
class: ["uk-button", "uk-button-primary"],
|
class: ["uk-button", "uk-button-primary"],
|
||||||
text: "Log In",
|
text: i18next.t("log_in_btn"),
|
||||||
attributes: {
|
attributes: {
|
||||||
type: "submit"
|
type: "submit"
|
||||||
}
|
}
|
||||||
|
@ -44,7 +45,7 @@ export class LoginPage extends Page {
|
||||||
attributes: {
|
attributes: {
|
||||||
required: true,
|
required: true,
|
||||||
type: "text",
|
type: "text",
|
||||||
placeholder: "Username",
|
placeholder: i18next.t("username_input"),
|
||||||
name: "username"
|
name: "username"
|
||||||
}
|
}
|
||||||
})),
|
})),
|
||||||
|
@ -55,14 +56,14 @@ export class LoginPage extends Page {
|
||||||
attributes: {
|
attributes: {
|
||||||
required: true,
|
required: true,
|
||||||
type: "password",
|
type: "password",
|
||||||
placeholder: "Password",
|
placeholder: i18next.t("password_input"),
|
||||||
name: "password"
|
name: "password"
|
||||||
}
|
}
|
||||||
})),
|
})),
|
||||||
MarginInline(makeElement({
|
MarginInline(makeElement({
|
||||||
tag: "button",
|
tag: "button",
|
||||||
class: ["uk-button", "uk-button-primary"],
|
class: ["uk-button", "uk-button-primary"],
|
||||||
text: "Log In",
|
text: i18next.t("log_in_btn"),
|
||||||
attributes: {
|
attributes: {
|
||||||
type: "submit"
|
type: "submit"
|
||||||
}
|
}
|
||||||
|
@ -83,14 +84,14 @@ export class LoginPage extends Page {
|
||||||
id: "tokenInput",
|
id: "tokenInput",
|
||||||
children: makeElement({
|
children: makeElement({
|
||||||
tag: "a",
|
tag: "a",
|
||||||
text: "Token"
|
text: i18next.t("log_in_with_token")
|
||||||
})
|
})
|
||||||
}),
|
}),
|
||||||
makeElement({
|
makeElement({
|
||||||
tag: "li",
|
tag: "li",
|
||||||
children: makeElement({
|
children: makeElement({
|
||||||
tag: "a",
|
tag: "a",
|
||||||
text: "Username"
|
text: i18next.t("log_in_with_username")
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
]
|
]
|
||||||
|
@ -144,6 +145,6 @@ export class LoginPage extends Page {
|
||||||
}
|
}
|
||||||
|
|
||||||
get name() {
|
get name() {
|
||||||
return "Login";
|
return i18next.t("log_in_title");
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,8 +1,9 @@
|
||||||
import { Page } from "../types/Page.js";
|
import { Page } from "../types/Page.js";
|
||||||
import { setPageContent } from "../pageUtils.js";
|
import { setPageContent } from "../pageUtils.js";
|
||||||
import { makeElement } from "../htmlUtils.js";
|
import { makeElement } from "../htmlUtils.js";
|
||||||
|
|
||||||
import { CopyableInputBox } from "../elements/CopyableInputBox.js";
|
import { CopyableInputBox } from "../elements/CopyableInputBox.js";
|
||||||
|
import i18next from 'i18next';
|
||||||
|
|
||||||
|
|
||||||
function random() {
|
function random() {
|
||||||
const {
|
const {
|
||||||
|
@ -40,7 +41,7 @@ export class PwGenPage extends Page {
|
||||||
inputBox,
|
inputBox,
|
||||||
makeElement({
|
makeElement({
|
||||||
tag: "button",
|
tag: "button",
|
||||||
text: "Gen New Password",
|
text: i18next.t("gen_password_btn"),
|
||||||
class: ["uk-button", "uk-button-primary", "uk-margin-bottom"],
|
class: ["uk-button", "uk-button-primary", "uk-margin-bottom"],
|
||||||
onclick: () => {
|
onclick: () => {
|
||||||
inputBox.setText(genPw(24));
|
inputBox.setText(genPw(24));
|
||||||
|
@ -51,6 +52,6 @@ export class PwGenPage extends Page {
|
||||||
}
|
}
|
||||||
|
|
||||||
get name() {
|
get name() {
|
||||||
return "Password Generator";
|
return i18next.t("password_generator_title");
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -25,7 +25,7 @@ export class SetLanguagePage extends Page {
|
||||||
return makeElement({
|
return makeElement({
|
||||||
tag: "option",
|
tag: "option",
|
||||||
text: i18next.getFixedT(languageID, null)("language_name"),
|
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");
|
let language = formData.get("language");
|
||||||
localStorage.setItem('language', language);
|
localStorage.setItem('language', language);
|
||||||
i18next.changeLanguage(language).then((t) => {
|
i18next.changeLanguage(language).then((t) => {
|
||||||
changePage("HOME", false);
|
changePage("HOME", false);
|
||||||
location.reload();
|
location.reload();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,4 +28,17 @@ module.exports = {
|
||||||
|
|
||||||
"set_language_title": "Set Language",
|
"set_language_title": "Set Language",
|
||||||
"set_language_btn": "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"
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in a new issue