fix(i18n): use English runtime text and localize system UI

This commit is contained in:
Arthur Koba
2026-10-25 19:44:15 +03:00
parent ada0550571
commit 65a96670d5
289 changed files with 8092 additions and 3426 deletions
+8 -4
View File
@@ -1,5 +1,7 @@
'use client';
import { useTranslations } from 'next-intl';
import {
createContext,
type ReactNode,
@@ -45,6 +47,7 @@ const UserContext = createContext<UserContextValue | undefined>(undefined);
* ```
*/
export function UserProvider({ children }: { children: ReactNode }) {
const t = useTranslations('contexts.user');
const [state, setState] = useState<UserState>({
user: null,
loading: true,
@@ -68,10 +71,10 @@ export function UserProvider({ children }: { children: ReactNode }) {
setState({
user: null,
loading: false,
error: error instanceof Error ? error.message : '获取用户信息失败',
error: error instanceof Error ? error.message : t('getUserInfoFailed'),
});
}
}, []);
}, [t]);
/** 重新获取用户信息 */
const refetch = useCallback(async () => {
@@ -97,14 +100,15 @@ export function UserProvider({ children }: { children: ReactNode }) {
throw error;
}
const errorMessage = error instanceof Error ? error.message : '登出失败';
const errorMessage =
error instanceof Error ? error.message : t('logoutFailed');
setState((prev) => ({
...prev,
error: errorMessage,
}));
throw new Error(errorMessage);
}
}, []);
}, [t]);
/** 组件挂载时获取用户信息(登录/注册页跳过,避免无意义请求) */
useEffect(() => {