From d14f15863d3f15395484e6d19f0aded98be1324e Mon Sep 17 00:00:00 2001 From: zxhlyh Date: Wed, 18 Oct 2023 16:00:56 +0800 Subject: [PATCH] fix: i18n runtime error (#1376) --- web/app/components/i18n-server.tsx | 2 -- web/app/components/i18n.tsx | 13 ++++++++----- web/i18n/i18next-config.ts | 5 +---- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/web/app/components/i18n-server.tsx b/web/app/components/i18n-server.tsx index 5707fa82c5..39a5f7ca1d 100644 --- a/web/app/components/i18n-server.tsx +++ b/web/app/components/i18n-server.tsx @@ -4,12 +4,10 @@ import { ToastProvider } from './base/toast' import { getDictionary, getLocaleOnServer } from '@/i18n/server' export type II18NServerProps = { - // locale: Locale children: React.ReactNode } const I18NServer = async ({ - // locale, children, }: II18NServerProps) => { const locale = getLocaleOnServer() diff --git a/web/app/components/i18n.tsx b/web/app/components/i18n.tsx index e64f958b30..32e1c93073 100644 --- a/web/app/components/i18n.tsx +++ b/web/app/components/i18n.tsx @@ -1,23 +1,26 @@ 'use client' import type { FC } from 'react' -import React from 'react' -import '@/i18n/i18next-config' +import React, { useEffect } from 'react' +import { changeLanguage } from '@/i18n/i18next-config' import I18NContext from '@/context/i18n' import type { Locale } from '@/i18n' -import { getLocaleOnClient, setLocaleOnClient } from '@/i18n/client' +import { setLocaleOnClient } from '@/i18n/client' export type II18nProps = { locale: Locale dictionary: Record children: React.ReactNode - setLocaleOnClient: (locale: Locale) => void } const I18n: FC = ({ + locale, dictionary, children, }) => { - const locale = getLocaleOnClient() + useEffect(() => { + changeLanguage(locale) + }, [locale]) + return (