diff --git a/src/allPages.ts b/src/allPages.ts index e57c5c0..f17cb40 100644 --- a/src/allPages.ts +++ b/src/allPages.ts @@ -10,7 +10,7 @@ import { MePage } from "./pages/Me"; import { NewTOTPPage } from "./pages/TOTP/NewTOTP.js"; import { Page } from "./types/Page"; import { PwGenPage } from "./pages/PwGen"; -import { SetLanguagePage } from "./pages/SetLanguage.js"; +import { SetLanguagePage } from "./pages/SetLanguage"; import { SetVaultURLPage } from "./pages/SetVaultURL.js"; import { TOTPViewPage } from "./pages/TOTP/TOTPView.js"; import { TransitDecryptPage } from "./pages/Transit/TransitDecrypt.js"; diff --git a/src/pages/SetLanguage.js b/src/pages/SetLanguage.ts similarity index 82% rename from src/pages/SetLanguage.js rename to src/pages/SetLanguage.ts index 67ab6c8..00c5cde 100644 --- a/src/pages/SetLanguage.js +++ b/src/pages/SetLanguage.ts @@ -2,18 +2,19 @@ import { Margin } from "../elements/Margin"; import { Page } from "../types/Page"; import { changePage, setPageContent } from "../pageUtils"; import { makeElement } from "../htmlUtils"; -import { pageState } from "../globalPageState.ts"; +import { pageState } from "../globalPageState"; import i18next from 'i18next'; +// @ts-ignore import translations from "../translations/index.mjs"; -let languageIDs = Object.getOwnPropertyNames(translations); +const languageIDs = Object.getOwnPropertyNames(translations); export class SetLanguagePage extends Page { constructor() { super(); } - render() { - let setLanguageForm = makeElement({ + render(): void { + const setLanguageForm = makeElement({ tag: "form", id: "setLanguageForm", children: [ @@ -46,12 +47,12 @@ export class SetLanguagePage extends Page { } }) ] - }); + }) as HTMLFormElement; setPageContent(setLanguageForm); setLanguageForm.addEventListener("submit", function (e) { e.preventDefault(); - let formData = new FormData(setLanguageForm); - let language = formData.get("language"); + const formData = new FormData(setLanguageForm); + const language = formData.get("language") as string; pageState.language = language; console.log(pageState.language); i18next.changeLanguage(language).then((t) => { @@ -61,7 +62,7 @@ export class SetLanguagePage extends Page { }); }); } - get name() { + get name(): string { return i18next.t("set_language_title"); } } diff --git a/webpack.config.js b/webpack.config.js index 87d1938..30ec592 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -26,7 +26,7 @@ module.exports = { }, resolve: { modules: ['node_modules'], - extensions: ['.tsx', '.ts', '.js'], + extensions: ['.tsx', '.ts', '.js', ".mjs"], }, module: {