Allow changing language without reloading page.
This commit is contained in:
parent
6914edbeb7
commit
2d0c1d7689
|
@ -5,9 +5,9 @@ import { makeElement } from "../htmlUtils";
|
|||
import { pageState } from "../globalPageState";
|
||||
import i18next from "i18next";
|
||||
|
||||
export function TitleBar(): HTMLElement {
|
||||
export function NavBar(): HTMLElement {
|
||||
return makeElement({
|
||||
id: "titleBar",
|
||||
id: "navBar",
|
||||
tag: "nav",
|
||||
class: ["uk-navbar", "uk-navbar-container"],
|
||||
children: [
|
||||
|
@ -55,7 +55,7 @@ export function TitleBar(): HTMLElement {
|
|||
})
|
||||
}
|
||||
|
||||
export function reloadTitleBar(): void {
|
||||
document.querySelector(".titleBar").replaceWith(TitleBar());
|
||||
export function reloadNavBar(): void {
|
||||
document.querySelector("#navBar").replaceWith(NavBar());
|
||||
}
|
||||
|
|
@ -25,7 +25,7 @@ import { getSealStatus } from "./api/sys/getSealStatus";
|
|||
import { makeElement } from "./htmlUtils";
|
||||
import { pageState } from "./globalPageState";
|
||||
import { playground } from "./playground";
|
||||
import { TitleBar } from "./elements/TitleBar";
|
||||
import { NavBar } from "./elements/NavBar";
|
||||
|
||||
// Translations
|
||||
import { formatDistance } from './formatDistance';
|
||||
|
@ -41,7 +41,7 @@ declare global {
|
|||
|
||||
function onLoad(): void {
|
||||
document.body.innerHTML = "";
|
||||
document.body.appendChild(TitleBar());
|
||||
document.body.appendChild(NavBar());
|
||||
document.body.appendChild(makeElement({
|
||||
tag: "div",
|
||||
class: ["uk-container", "uk-container-medium", "uk-align-center"],
|
||||
|
|
|
@ -4,7 +4,7 @@ import { changePage, setPageContent } from "../pageUtils";
|
|||
import { makeElement } from "../htmlUtils";
|
||||
import { pageState } from "../globalPageState";
|
||||
import i18next from 'i18next';
|
||||
import { reloadTitleBar } from "../elements/TitleBar";
|
||||
import { reloadNavBar } from "../elements/NavBar";
|
||||
|
||||
// @ts-ignore
|
||||
import translations from "../translations/index.mjs";
|
||||
|
@ -59,7 +59,7 @@ export class SetLanguagePage extends Page {
|
|||
console.log(pageState.language);
|
||||
void i18next.changeLanguage(language).then((t) => {
|
||||
pageState.pageDirection = t("language_direction");
|
||||
reloadTitleBar();
|
||||
reloadNavBar();
|
||||
changePage("HOME");
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue