feat(admin): enhance login form with language switcher and update script handling
- Added AdminLanguageSwitcher to the login form for improved language selection. - Replaced inline script with next/script component for better performance and safety in layout.tsx. - Updated language initialization logic to ensure consistent SSR and client rendering.
This commit is contained in:
@@ -6,7 +6,6 @@ import { initReactI18next } from "react-i18next";
|
||||
import {
|
||||
adminHtmlLang,
|
||||
applyAdminUiLocale,
|
||||
getStoredAdminUiLocale,
|
||||
hydrateAdminUiLocale,
|
||||
type AdminApiLocale,
|
||||
} from "@/lib/admin-locale";
|
||||
@@ -124,16 +123,9 @@ export function normalizeAdminLanguage(lang: string | undefined): AdminLanguage
|
||||
}
|
||||
|
||||
function getInitialAdminLanguage(): AdminLanguage {
|
||||
if (typeof window === "undefined") {
|
||||
return ADMIN_DEFAULT_LANGUAGE;
|
||||
}
|
||||
|
||||
const stored = getStoredAdminUiLocale();
|
||||
if (stored) {
|
||||
return stored;
|
||||
}
|
||||
|
||||
return normalizeAdminLanguage(document.documentElement.lang);
|
||||
// Keep SSR and first client render aligned to avoid hydration mismatch.
|
||||
// Stored locale is applied after mount in `Providers`.
|
||||
return ADMIN_DEFAULT_LANGUAGE;
|
||||
}
|
||||
|
||||
function syncAdminLanguage(lang: AdminLanguage): void {
|
||||
|
||||
Reference in New Issue
Block a user