mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-12 10:48:59 +08:00
fix: i18n runtime error (#1376)
This commit is contained in:
parent
7c9b585a47
commit
d14f15863d
@ -4,12 +4,10 @@ import { ToastProvider } from './base/toast'
|
|||||||
import { getDictionary, getLocaleOnServer } from '@/i18n/server'
|
import { getDictionary, getLocaleOnServer } from '@/i18n/server'
|
||||||
|
|
||||||
export type II18NServerProps = {
|
export type II18NServerProps = {
|
||||||
// locale: Locale
|
|
||||||
children: React.ReactNode
|
children: React.ReactNode
|
||||||
}
|
}
|
||||||
|
|
||||||
const I18NServer = async ({
|
const I18NServer = async ({
|
||||||
// locale,
|
|
||||||
children,
|
children,
|
||||||
}: II18NServerProps) => {
|
}: II18NServerProps) => {
|
||||||
const locale = getLocaleOnServer()
|
const locale = getLocaleOnServer()
|
||||||
|
@ -1,23 +1,26 @@
|
|||||||
'use client'
|
'use client'
|
||||||
|
|
||||||
import type { FC } from 'react'
|
import type { FC } from 'react'
|
||||||
import React from 'react'
|
import React, { useEffect } from 'react'
|
||||||
import '@/i18n/i18next-config'
|
import { changeLanguage } from '@/i18n/i18next-config'
|
||||||
import I18NContext from '@/context/i18n'
|
import I18NContext from '@/context/i18n'
|
||||||
import type { Locale } from '@/i18n'
|
import type { Locale } from '@/i18n'
|
||||||
import { getLocaleOnClient, setLocaleOnClient } from '@/i18n/client'
|
import { setLocaleOnClient } from '@/i18n/client'
|
||||||
|
|
||||||
export type II18nProps = {
|
export type II18nProps = {
|
||||||
locale: Locale
|
locale: Locale
|
||||||
dictionary: Record<string, any>
|
dictionary: Record<string, any>
|
||||||
children: React.ReactNode
|
children: React.ReactNode
|
||||||
setLocaleOnClient: (locale: Locale) => void
|
|
||||||
}
|
}
|
||||||
const I18n: FC<II18nProps> = ({
|
const I18n: FC<II18nProps> = ({
|
||||||
|
locale,
|
||||||
dictionary,
|
dictionary,
|
||||||
children,
|
children,
|
||||||
}) => {
|
}) => {
|
||||||
const locale = getLocaleOnClient()
|
useEffect(() => {
|
||||||
|
changeLanguage(locale)
|
||||||
|
}, [locale])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<I18NContext.Provider value={{
|
<I18NContext.Provider value={{
|
||||||
locale,
|
locale,
|
||||||
|
@ -33,9 +33,6 @@ import datasetCreationEn from './lang/dataset-creation.en'
|
|||||||
import datasetCreationZh from './lang/dataset-creation.zh'
|
import datasetCreationZh from './lang/dataset-creation.zh'
|
||||||
import exploreEn from './lang/explore.en'
|
import exploreEn from './lang/explore.en'
|
||||||
import exploreZh from './lang/explore.zh'
|
import exploreZh from './lang/explore.zh'
|
||||||
import { getLocaleOnClient } from '@/i18n/client'
|
|
||||||
|
|
||||||
const localLng = getLocaleOnClient()
|
|
||||||
|
|
||||||
const resources = {
|
const resources = {
|
||||||
'en': {
|
'en': {
|
||||||
@ -88,7 +85,7 @@ i18n.use(initReactI18next)
|
|||||||
// init i18next
|
// init i18next
|
||||||
// for all options read: https://www.i18next.com/overview/configuration-options
|
// for all options read: https://www.i18next.com/overview/configuration-options
|
||||||
.init({
|
.init({
|
||||||
lng: localLng,
|
lng: undefined,
|
||||||
fallbackLng: 'en',
|
fallbackLng: 'en',
|
||||||
// debug: true,
|
// debug: true,
|
||||||
resources,
|
resources,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user