Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
dify
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ai-tech
dify
Commits
d14f1586
Unverified
Commit
d14f1586
authored
Oct 18, 2023
by
zxhlyh
Committed by
GitHub
Oct 18, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: i18n runtime error (#1376)
parent
7c9b585a
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
11 deletions
+9
-11
i18n-server.tsx
web/app/components/i18n-server.tsx
+0
-2
i18n.tsx
web/app/components/i18n.tsx
+8
-5
i18next-config.ts
web/i18n/i18next-config.ts
+1
-4
No files found.
web/app/components/i18n-server.tsx
View file @
d14f1586
...
@@ -4,12 +4,10 @@ import { ToastProvider } from './base/toast'
...
@@ -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
()
...
...
web/app/components/i18n.tsx
View file @
d14f1586
'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
,
...
...
web/i18n/i18next-config.ts
View file @
d14f1586
...
@@ -33,9 +33,6 @@ import datasetCreationEn from './lang/dataset-creation.en'
...
@@ -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)
...
@@ -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
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment