Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

fix: i18n runtime error (#1376)

zxhlyhd14f15863d3f
diff --git a/web/app/components/i18n-server.tsx b/web/app/components/i18n-server.tsx
index 5707fa82c59..39a5f7ca1d1 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 e64f958b309..32e1c930731 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<string, any>
children: React.ReactNode
- setLocaleOnClient: (locale: Locale) => void
}
const I18n: FC<II18nProps> = ({
+ locale,
dictionary,
children,
}) => {
- const locale = getLocaleOnClient()
+ useEffect(() => {
+ changeLanguage(locale)
+ }, [locale])
+
return (
<I18NContext.Provider value={{
locale,
diff --git a/web/i18n/i18next-config.ts b/web/i18n/i18next-config.ts
index 3f0c45f81c7..104c85f8a45 100644
--- a/web/i18n/i18next-config.ts
+++ b/web/i18n/i18next-config.ts
@@ -33,9 +33,6 @@ import datasetCreationEn from './lang/dataset-creation.en'
import datasetCreationZh from './lang/dataset-creation.zh'
import exploreEn from './lang/explore.en'
import exploreZh from './lang/explore.zh'
-import { getLocaleOnClient } from '@/i18n/client'
-
-const localLng = getLocaleOnClient()
const resources = {
'en': {
@@ -88,7 +85,7 @@ i18n.use(initReactI18next)
// init i18next
// for all options read: https://www.i18next.com/overview/configuration-options
.init({
- lng: localLng,
+ lng: undefined,
fallbackLng: 'en',
// debug: true,
resources,