diff --git a/web/app/components/header/account-setting/language-page/index.tsx b/web/app/components/header/account-setting/language-page/index.tsx index 7d3e09fc21..ba0c149ae7 100644 --- a/web/app/components/header/account-setting/language-page/index.tsx +++ b/web/app/components/header/account-setting/language-page/index.tsx @@ -32,7 +32,7 @@ export default function LanguagePage() { await updateUserProfile({ url, body: { [bodyKey]: item.value } }) notify({ type: 'success', message: t('common.actionMsg.modifiedSuccessfully') }) - setLocaleOnClient(item.value.toString()) + await setLocaleOnClient(item.value.toString()) } catch (e) { notify({ type: 'error', message: (e as Error).message }) diff --git a/web/app/components/i18n.tsx b/web/app/components/i18n.tsx index f04f8d6cbe..2493e5b5af 100644 --- a/web/app/components/i18n.tsx +++ b/web/app/components/i18n.tsx @@ -1,10 +1,11 @@ 'use client' import type { FC } from 'react' -import React, { useEffect } from 'react' +import React, { useEffect, useState } from 'react' import I18NContext from '@/context/i18n' import type { Locale } from '@/i18n' import { setLocaleOnClient } from '@/i18n' +import Loading from './base/loading' export type II18nProps = { locale: Locale @@ -14,10 +15,17 @@ const I18n: FC = ({ locale, children, }) => { + const [loading, setLoading] = useState(true) + useEffect(() => { - setLocaleOnClient(locale, false) + setLocaleOnClient(locale, false).then(() => { + setLoading(false) + }) }, [locale]) + if (loading) + return
+ return ( {