feat: 添加国际化支持,优化语言切换器和登录界面,增强用户体验
Some checks failed
lotteryfront CI / build (push) Has been cancelled

This commit is contained in:
2026-06-29 15:27:37 +08:00
parent 1a43e81fb4
commit ebc6f4d349
8 changed files with 181 additions and 100 deletions

View File

@@ -0,0 +1,25 @@
"use client";
import { createContext, useContext, useEffect, useState, type ReactNode } from "react";
import { syncPreferredLanguage } from "@/i18n";
const I18nHydrationContext = createContext(false);
/** hydration 完成前保持 DEFAULT_LANGUAGE与 SSR 一致;完成后再同步用户偏好语言。 */
export function I18nHydrationProvider({ children }: { children: ReactNode }) {
const [hydrated, setHydrated] = useState(false);
useEffect(() => {
syncPreferredLanguage();
setHydrated(true);
}, []);
return (
<I18nHydrationContext.Provider value={hydrated}>{children}</I18nHydrationContext.Provider>
);
}
export function useI18nHydrated(): boolean {
return useContext(I18nHydrationContext);
}