1
0
Fork 0

Add en translations for Password Generator and Login pages.

This commit is contained in:
Kitteh 2021-04-20 20:19:34 +01:00
parent 71eda16ec3
commit cc61c26264
5 changed files with 37 additions and 14 deletions

View file

@ -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

View file

@ -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");
}
}

View file

@ -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");
}
}

View file

@ -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();
});
});
}

View file

@ -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"
}