mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-07-15 21:03:47 +00:00
Guard language switching failures (#1002)
This commit is contained in:
@@ -41,7 +41,7 @@ import type { SSOProviderPublic } from "@/types/index";
|
||||
import { ElectronServerConfig as ServerConfigComponent } from "@/auth/ElectronServerConfig";
|
||||
import { ElectronLoginForm } from "@/auth/ElectronLoginForm";
|
||||
import { Checkbox } from "@/components/checkbox";
|
||||
import i18n from "@/i18n/i18n";
|
||||
import { changeAppLanguage, normalizeLanguageCode } from "@/i18n/i18n";
|
||||
import {
|
||||
removeSilentSigninFromSearch,
|
||||
shouldTriggerSilentSignin,
|
||||
@@ -238,14 +238,14 @@ export function Auth({ onLogin }: AuthProps) {
|
||||
const [confirmNewPassword, setConfirmNewPassword] = useState("");
|
||||
const [resetTempToken, setResetTempToken] = useState("");
|
||||
|
||||
const [language, setLanguage] = useState(
|
||||
() => localStorage.getItem("i18nextLng") ?? "en",
|
||||
const [language, setLanguage] = useState(() =>
|
||||
normalizeLanguageCode(localStorage.getItem("i18nextLng")),
|
||||
);
|
||||
|
||||
function handleLanguageChange(code: string) {
|
||||
setLanguage(code);
|
||||
localStorage.setItem("i18nextLng", code);
|
||||
i18n.changeLanguage(code);
|
||||
void changeAppLanguage(code)
|
||||
.then((language) => setLanguage(language))
|
||||
.catch(() => {});
|
||||
}
|
||||
|
||||
const [registrationAllowed, setRegistrationAllowed] = useState(true);
|
||||
|
||||
Reference in New Issue
Block a user