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.

refactor(i18n): separate runtime and metadata boundaries (#42471)

yyhd43594822bf2
diff --git a/oxlint-suppressions.json b/oxlint-suppressions.json
index fad85761d11..4e24a27e408 100644
--- a/oxlint-suppressions.json
+++ b/oxlint-suppressions.json
@@ -5174,11 +5174,6 @@
"count": 1
}
},
- "web/i18n-config/lib.client.ts": {
- "no-barrel-files/no-barrel-files": {
- "count": 1
- }
- },
"web/models/datasets.ts": {
"erasable-syntax-only/enums": {
"count": 7
diff --git a/web/__tests__/billing/billing-integration.test.tsx b/web/__tests__/billing/billing-integration.test.tsx
index cb41580ac00..30efc0f7c86 100644
--- a/web/__tests__/billing/billing-integration.test.tsx
+++ b/web/__tests__/billing/billing-integration.test.tsx
@@ -67,6 +67,10 @@ vi.mock('@/context/workspace-state', async () => {
vi.mock('@/context/i18n', () => ({
useGetLanguage: () => 'en-US',
+}))
+
+vi.mock('#i18n', async (importOriginal) => ({
+ ...(await importOriginal<typeof import('#i18n')>()),
useLocale: () => 'en-US',
}))
diff --git a/web/__tests__/billing/pricing-modal-flow.test.tsx b/web/__tests__/billing/pricing-modal-flow.test.tsx
index 40ffa9370a4..ee154ba178a 100644
--- a/web/__tests__/billing/pricing-modal-flow.test.tsx
+++ b/web/__tests__/billing/pricing-modal-flow.test.tsx
@@ -60,6 +60,10 @@ vi.mock('@/context/workspace-state', async () => {
})
vi.mock('@/context/i18n', () => ({
useGetLanguage: () => 'en-US',
+}))
+
+vi.mock('#i18n', async (importOriginal) => ({
+ ...(await importOriginal<typeof import('#i18n')>()),
useLocale: () => 'en-US',
}))
diff --git a/web/app/(commonLayout)/app/(appDetailLayout)/[appId]/overview/time-range-picker/index.tsx b/web/app/(commonLayout)/app/(appDetailLayout)/[appId]/overview/time-range-picker/index.tsx
index 1977fd053bb..401424965b6 100644
--- a/web/app/(commonLayout)/app/(appDetailLayout)/[appId]/overview/time-range-picker/index.tsx
+++ b/web/app/(commonLayout)/app/(appDetailLayout)/[appId]/overview/time-range-picker/index.tsx
@@ -9,8 +9,8 @@ import type { I18nKeysByPrefix } from '@/types/i18n'
import dayjs from 'dayjs'
import * as React from 'react'
import { useCallback, useState } from 'react'
+import { useLocale } from '#i18n'
import { HourglassShape } from '@/app/components/base/icons/src/vender/other'
-import { useLocale } from '@/context/i18n'
import { formatToLocalTime } from '@/utils/format'
import DatePicker from './date-picker'
import RangeSelector from './range-selector'
diff --git a/web/app/(shareLayout)/webapp-reset-password/check-code/page.tsx b/web/app/(shareLayout)/webapp-reset-password/check-code/page.tsx
index 0e378cd8e2e..9f7d89ca924 100644
--- a/web/app/(shareLayout)/webapp-reset-password/check-code/page.tsx
+++ b/web/app/(shareLayout)/webapp-reset-password/check-code/page.tsx
@@ -5,8 +5,8 @@ import { toast } from '@langgenius/dify-ui/toast'
import { RiArrowLeftLine, RiMailSendFill } from '@remixicon/react'
import { useState } from 'react'
import { useTranslation } from 'react-i18next'
+import { useLocale } from '#i18n'
import Countdown from '@/app/components/signin/countdown'
-import { useLocale } from '@/context/i18n'
import useDocumentTitle from '@/hooks/use-document-title'
import { useRouter, useSearchParams } from '@/next/navigation'
import { sendWebAppResetPasswordCode, verifyWebAppResetPasswordCode } from '@/service/common'
diff --git a/web/app/(shareLayout)/webapp-reset-password/page.tsx b/web/app/(shareLayout)/webapp-reset-password/page.tsx
index 9c0fd0e2b34..99449d9d568 100644
--- a/web/app/(shareLayout)/webapp-reset-password/page.tsx
+++ b/web/app/(shareLayout)/webapp-reset-password/page.tsx
@@ -6,9 +6,9 @@ import { RiArrowLeftLine, RiLockPasswordLine } from '@remixicon/react'
import { noop } from 'es-toolkit/function'
import { useState } from 'react'
import { useTranslation } from 'react-i18next'
+import { useLocale } from '#i18n'
import { COUNT_DOWN_TIME_MS, useSetCountdownLeftTime } from '@/app/components/signin/storage'
import { emailRegex } from '@/config'
-import { useLocale } from '@/context/i18n'
import useDocumentTitle from '@/hooks/use-document-title'
import Link from '@/next/link'
import { useRouter, useSearchParams } from '@/next/navigation'
diff --git a/web/app/(shareLayout)/webapp-signin/check-code/page.tsx b/web/app/(shareLayout)/webapp-signin/check-code/page.tsx
index f586ae17452..e6a953db618 100644
--- a/web/app/(shareLayout)/webapp-signin/check-code/page.tsx
+++ b/web/app/(shareLayout)/webapp-signin/check-code/page.tsx
@@ -5,12 +5,12 @@ import { Input } from '@langgenius/dify-ui/input'
import { toast } from '@langgenius/dify-ui/toast'
import { useEffect, useRef, useState } from 'react'
import { useTranslation } from 'react-i18next'
+import { useLocale } from '#i18n'
import {
navigateAfterWebAppLogin,
resolveWebAppLoginRedirect,
} from '@/app/(shareLayout)/webapp-signin/login-redirect'
import Countdown from '@/app/components/signin/countdown'
-import { useLocale } from '@/context/i18n'
import { useWebAppStore } from '@/context/web-app-context'
import { useRouter, useSearchParams } from '@/next/navigation'
import { sendWebAppEMailLoginCode, webAppEmailLoginWithCode } from '@/service/common'
diff --git a/web/app/(shareLayout)/webapp-signin/components/__tests__/mail-and-code-auth.spec.tsx b/web/app/(shareLayout)/webapp-signin/components/__tests__/mail-and-code-auth.spec.tsx
index e0765426bcc..68eed546fc5 100644
--- a/web/app/(shareLayout)/webapp-signin/components/__tests__/mail-and-code-auth.spec.tsx
+++ b/web/app/(shareLayout)/webapp-signin/components/__tests__/mail-and-code-auth.spec.tsx
@@ -15,7 +15,8 @@ vi.mock('@/next/navigation', () => ({
useSearchParams: () => searchParams,
}))
-vi.mock('@/context/i18n', () => ({
+vi.mock('#i18n', async (importOriginal) => ({
+ ...(await importOriginal<typeof import('#i18n')>()),
useLocale: () => 'en-US',
}))
diff --git a/web/app/(shareLayout)/webapp-signin/components/__tests__/mail-and-password-auth.spec.tsx b/web/app/(shareLayout)/webapp-signin/components/__tests__/mail-and-password-auth.spec.tsx
index 4c39b09f9f3..7bf924ba467 100644
--- a/web/app/(shareLayout)/webapp-signin/components/__tests__/mail-and-password-auth.spec.tsx
+++ b/web/app/(shareLayout)/webapp-signin/components/__tests__/mail-and-password-auth.spec.tsx
@@ -14,7 +14,8 @@ vi.mock('@/next/navigation', () => ({
useSearchParams: () => searchParams,
}))
-vi.mock('@/context/i18n', () => ({
+vi.mock('#i18n', async (importOriginal) => ({
+ ...(await importOriginal<typeof import('#i18n')>()),
useLocale: () => 'en-US',
}))
diff --git a/web/app/(shareLayout)/webapp-signin/components/mail-and-code-auth.tsx b/web/app/(shareLayout)/webapp-signin/components/mail-and-code-auth.tsx
index 3906b57fe63..bb67ca8e891 100644
--- a/web/app/(shareLayout)/webapp-signin/components/mail-and-code-auth.tsx
+++ b/web/app/(shareLayout)/webapp-signin/components/mail-and-code-auth.tsx
@@ -3,10 +3,10 @@ import { Input } from '@langgenius/dify-ui/input'
import { toast } from '@langgenius/dify-ui/toast'
import { useEffect, useState } from 'react'
import { useTranslation } from 'react-i18next'
+import { useLocale } from '#i18n'
import { resolveWebAppLoginRedirect } from '@/app/(shareLayout)/webapp-signin/login-redirect'
import { COUNT_DOWN_TIME_MS, useSetCountdownLeftTime } from '@/app/components/signin/storage'
import { emailRegex } from '@/config'
-import { useLocale } from '@/context/i18n'
import { useRouter, useSearchParams } from '@/next/navigation'
import { sendWebAppEMailLoginCode } from '@/service/common'
import { getClientLoginFallback } from '@/utils/login-redirect'
diff --git a/web/app/__tests__/home-banner.browser.spec.tsx b/web/app/__tests__/home-banner.browser.spec.tsx
index 9a3595dba19..c6d4f913e70 100644
--- a/web/app/__tests__/home-banner.browser.spec.tsx
+++ b/web/app/__tests__/home-banner.browser.spec.tsx
@@ -17,7 +17,8 @@ vi.mock('@/features/account-profile/client', () => ({
userProfileQueryOptions: () => ({}),
}))
-vi.mock('@/context/i18n', () => ({
+vi.mock('#i18n', async (importOriginal) => ({
+ ...(await importOriginal<typeof import('#i18n')>()),
useLocale: () => 'en-US',
}))
diff --git a/web/app/components/app/access-config/index.tsx b/web/app/components/app/access-config/index.tsx
index 79acb7e7b3c..8474749131e 100644
--- a/web/app/components/app/access-config/index.tsx
+++ b/web/app/components/app/access-config/index.tsx
@@ -5,9 +5,9 @@ import { useSuspenseQuery } from '@tanstack/react-query'
import { useAtomValue } from 'jotai'
import { useCallback, useMemo, useState } from 'react'
import { useTranslation } from 'react-i18next'
+import { useLocale } from '#i18n'
import AccessRulesEditor from '@/app/components/access-rules-editor'
import { useStore } from '@/app/components/app/store'
-import { useLocale } from '@/context/i18n'
import { workspacePermissionKeysAtom } from '@/context/permission-state'
import { userProfileQueryOptions } from '@/features/account-profile/client'
import { systemFeaturesQueryOptions } from '@/features/system-features/client'
diff --git a/web/app/components/app/annotation/batch-add-annotation-modal/__tests__/csv-downloader.spec.tsx b/web/app/components/app/annotation/batch-add-annotation-modal/__tests__/csv-downloader.spec.tsx
index d43e14c0fe1..2587af7eca8 100644
--- a/web/app/components/app/annotation/batch-add-annotation-modal/__tests__/csv-downloader.spec.tsx
+++ b/web/app/components/app/annotation/batch-add-annotation-modal/__tests__/csv-downloader.spec.tsx
@@ -2,11 +2,12 @@ import type { Mock } from 'vite-plus/test'
import type { Locale } from '@/i18n-config'
import { render, screen } from '@testing-library/react'
import * as React from 'react'
-import { useLocale } from '@/context/i18n'
+import { useLocale } from '#i18n'
import { LanguagesSupported } from '@/i18n-config/language'
import CSVDownload from '../csv-downloader'
-vi.mock('@/context/i18n', () => ({
+vi.mock('#i18n', async (importOriginal) => ({
+ ...(await importOriginal<typeof import('#i18n')>()),
useLocale: vi.fn(() => 'en-US'),
}))
diff --git a/web/app/components/app/annotation/batch-add-annotation-modal/csv-downloader.tsx b/web/app/components/app/annotation/batch-add-annotation-modal/csv-downloader.tsx
index 69fa82bbbdb..aa5bdcdb140 100644
--- a/web/app/components/app/annotation/batch-add-annotation-modal/csv-downloader.tsx
+++ b/web/app/components/app/annotation/batch-add-annotation-modal/csv-downloader.tsx
@@ -3,8 +3,8 @@ import type { FC } from 'react'
import * as React from 'react'
import { useTranslation } from 'react-i18next'
import { useCSVDownloader } from 'react-papaparse'
+import { useLocale } from '#i18n'
import { Download02 as DownloadIcon } from '@/app/components/base/icons/src/vender/solid/general'
-import { useLocale } from '@/context/i18n'
import { LanguagesSupported } from '@/i18n-config/language'
const CSV_TEMPLATE_QA_EN = [
diff --git a/web/app/components/app/annotation/header-opts/__tests__/index.spec.tsx b/web/app/components/app/annotation/header-opts/__tests__/index.spec.tsx
index 374affd754e..536fd0379d2 100644
--- a/web/app/components/app/annotation/header-opts/__tests__/index.spec.tsx
+++ b/web/app/components/app/annotation/header-opts/__tests__/index.spec.tsx
@@ -4,7 +4,7 @@ import type { AnnotationItemBasic } from '../../type'
import type { Locale } from '@/i18n-config'
import { act, screen, waitFor } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
-import { useLocale } from '@/context/i18n'
+import { useLocale } from '#i18n'
import { LanguagesSupported } from '@/i18n-config/language'
import { clearAllAnnotations, fetchExportAnnotationList } from '@/service/annotation'
import { renderWithConsoleQuery as render } from '@/test/console/query-data'
@@ -30,7 +30,8 @@ vi.mock('@/app/components/billing/annotation-full', () => ({
default: () => <div data-testid="annotation-full" />,
}))
-vi.mock('@/context/i18n', () => ({
+vi.mock('#i18n', async (importOriginal) => ({
+ ...(await importOriginal<typeof import('#i18n')>()),
useLocale: vi.fn(() => LanguagesSupported[0]),
}))
diff --git a/web/app/components/app/annotation/header-opts/index.tsx b/web/app/components/app/annotation/header-opts/index.tsx
index c4de0662292..6f43e75229e 100644
--- a/web/app/components/app/annotation/header-opts/index.tsx
+++ b/web/app/components/app/annotation/header-opts/index.tsx
@@ -15,7 +15,7 @@ import * as React from 'react'
import { useEffect, useState } from 'react'
import { useTranslation } from 'react-i18next'
import { jsonToCSV } from 'react-papaparse'
-import { useLocale } from '@/context/i18n'
+import { useLocale } from '#i18n'
import { LanguagesSupported } from '@/i18n-config/language'
import { clearAllAnnotations, fetchExportAnnotationList } from '@/service/annotation'
import { downloadBlob } from '@/utils/download'
diff --git a/web/app/components/app/app-publisher/publish-with-multiple-model.tsx b/web/app/components/app/app-publisher/publish-with-multiple-model.tsx
index 299e62f2c84..84ab304263f 100644
--- a/web/app/components/app/app-publisher/publish-with-multiple-model.tsx
+++ b/web/app/components/app/app-publisher/publish-with-multiple-model.tsx
@@ -17,7 +17,7 @@ import { useState } from 'react'
import { useTranslation } from 'react-i18next'
import { ModelTypeEnum } from '@/app/components/header/account-setting/model-provider-page/declarations'
import { useLanguage } from '@/app/components/header/account-setting/model-provider-page/hooks'
-import { renderI18nObject } from '@/i18n-config'
+import { renderI18nObject } from '@/i18n-config/metadata'
import { consoleQuery } from '@/service/console'
import ModelIcon from '../../header/account-setting/model-provider-page/model-icon'
diff --git a/web/app/components/app/configuration/config/agent/agent-tools/setting-built-in-tool.tsx b/web/app/components/app/configuration/config/agent/agent-tools/setting-built-in-tool.tsx
index 1d5cd5c7dde..d907e9e106f 100644
--- a/web/app/components/app/configuration/config/agent/agent-tools/setting-built-in-tool.tsx
+++ b/web/app/components/app/configuration/config/agent/agent-tools/setting-built-in-tool.tsx
@@ -17,6 +17,7 @@ import { RiArrowLeftLine, RiCloseLine } from '@remixicon/react'
import * as React from 'react'
import { useEffect, useState } from 'react'
import { useTranslation } from 'react-i18next'
+import { useLocale } from '#i18n'
import Loading from '@/app/components/base/loading'
import TabSlider from '@/app/components/base/tab-slider-plain'
import Form from '@/app/components/header/account-setting/model-provider-page/model-modal/Form'
@@ -27,8 +28,7 @@ import { AuthCategory, PluginAuthInAgent } from '@/app/components/plugins/plugin
import { ReadmeEntrance } from '@/app/components/plugins/readme-panel/entrance'
import { CollectionType } from '@/app/components/tools/types'
import { toolParametersToFormSchemas } from '@/app/components/tools/utils/to-form-schema'
-import { useLocale } from '@/context/i18n'
-import { getLanguage } from '@/i18n-config/language'
+import { getPluginLanguage } from '@/i18n-config/metadata'
import {
fetchBuiltInToolList,
fetchCustomToolList,
@@ -66,7 +66,7 @@ const SettingBuiltInTool: FC<Props> = ({
onAuthorizationItemClick,
}) => {
const locale = useLocale()
- const language = getLanguage(locale)
+ const language = getPluginLanguage(locale)
const { t } = useTranslation()
const passedTools = (collection as ToolWithProvider).tools
const hasPassedTools = passedTools?.length > 0
diff --git a/web/app/components/app/configuration/tools/__tests__/external-data-tool-modal.spec.tsx b/web/app/components/app/configuration/tools/__tests__/external-data-tool-modal.spec.tsx
index 5169868b53a..099c7305771 100644
--- a/web/app/components/app/configuration/tools/__tests__/external-data-tool-modal.spec.tsx
+++ b/web/app/components/app/configuration/tools/__tests__/external-data-tool-modal.spec.tsx
@@ -13,6 +13,10 @@ vi.mock('@/app/components/app/configuration/toast', () => ({
vi.mock('@/context/i18n', () => ({
useDocLink: () => (path: string) => `https://docs.example.com${path}`,
+}))
+
+vi.mock('#i18n', async (importOriginal) => ({
+ ...(await importOriginal<typeof import('#i18n')>()),
useLocale: () => mockLocale,
}))
diff --git a/web/app/components/app/configuration/tools/external-data-tool-modal.tsx b/web/app/components/app/configuration/tools/external-data-tool-modal.tsx
index 3cbff54a4f4..86b64daadb0 100644
--- a/web/app/components/app/configuration/tools/external-data-tool-modal.tsx
+++ b/web/app/components/app/configuration/tools/external-data-tool-modal.tsx
@@ -14,13 +14,14 @@ import {
import { noop } from 'es-toolkit/function'
import { useState } from 'react'
import { useTranslation } from 'react-i18next'
+import { useLocale } from '#i18n'
import { toast } from '@/app/components/app/configuration/toast'
import AppIcon from '@/app/components/base/app-icon'
import EmojiPicker from '@/app/components/base/emoji-picker'
import FormGeneration from '@/app/components/base/features/new-feature-panel/moderation/form-generation'
import { BookOpen01 } from '@/app/components/base/icons/src/vender/line/education'
import { ApiBasedExtensionSelector } from '@/app/components/header/account-setting/api-based-extension-page/selector'
-import { useDocLink, useLocale } from '@/context/i18n'
+import { useDocLink } from '@/context/i18n'
import { useCodeBasedExtensions } from '@/service/use-common'
import {
buildProviders,
diff --git a/web/app/components/app/deploy/__tests__/index.spec.tsx b/web/app/components/app/deploy/__tests__/index.spec.tsx
index 956e7dc3592..d5c1995c346 100644
--- a/web/app/components/app/deploy/__tests__/index.spec.tsx
+++ b/web/app/components/app/deploy/__tests__/index.spec.tsx
@@ -846,6 +846,10 @@ vi.mock('@/context/permission-state', async () => {
vi.mock('@/context/i18n', () => ({
getEnterpriseDocUrl: mockGetEnterpriseDocUrl,
+}))
+
+vi.mock('#i18n', async (importOriginal) => ({
+ ...(await importOriginal<typeof import('#i18n')>()),
useLocale: () => 'en-US',
}))
diff --git a/web/app/components/app/deploy/index.tsx b/web/app/components/app/deploy/index.tsx
index 2b82aabfb7f..2b880fd54cf 100644
--- a/web/app/components/app/deploy/index.tsx
+++ b/web/app/components/app/deploy/index.tsx
@@ -10,9 +10,10 @@ import { useSuspenseQuery } from '@tanstack/react-query'
import { useAtomValue } from 'jotai'
import { useCallback, useState } from 'react'
import { useTranslation } from 'react-i18next'
+import { useLocale } from '#i18n'
import { useStore as useAppStore } from '@/app/components/app/store'
import Loading from '@/app/components/base/loading'
-import { getEnterpriseDocUrl, useLocale } from '@/context/i18n'
+import { getEnterpriseDocUrl } from '@/context/i18n'
import { workspacePermissionKeysAtom } from '@/context/permission-state'
import { userProfileQueryOptions } from '@/features/account-profile/client'
import { getDocLanguage } from '@/i18n-config/language'
diff --git a/web/app/components/app/in-site-message/__tests__/notification.spec.tsx b/web/app/components/app/in-site-message/__tests__/notification.spec.tsx
index 813166e71e0..8b7d21e3577 100644
--- a/web/app/components/app/in-site-message/__tests__/notification.spec.tsx
+++ b/web/app/components/app/in-site-message/__tests__/notification.spec.tsx
@@ -12,7 +12,8 @@ const { mockEdition, mockLocale, mockNotification, mockNotificationDismiss } = v
mockNotificationDismiss: vi.fn(),
}))
-vi.mock('@/context/i18n', () => ({
+vi.mock('#i18n', async (importOriginal) => ({
+ ...(await importOriginal<typeof import('#i18n')>()),
useLocale: () => mockLocale.value,
}))
diff --git a/web/app/components/app/in-site-message/notification.tsx b/web/app/components/app/in-site-message/notification.tsx
index f18e4bc87d0..753b37d6f1c 100644
--- a/web/app/components/app/in-site-message/notification.tsx
+++ b/web/app/components/app/in-site-message/notification.tsx
@@ -3,7 +3,7 @@
import type { InSiteMessageActionItem } from './index'
import { useMutation, useQuery, useSuspenseQuery } from '@tanstack/react-query'
import { useTranslation } from 'react-i18next'
-import { useLocale } from '@/context/i18n'
+import { useLocale } from '#i18n'
import { systemFeaturesQueryOptions } from '@/features/system-features/client'
import { consoleQuery } from '@/service/console'
import InSiteMessage from './index'
diff --git a/web/app/components/base/agent-log-modal/__tests__/tool-call.spec.tsx b/web/app/components/base/agent-log-modal/__tests__/tool-call.spec.tsx
index 4dc0d91ce60..a0f2bff8474 100644
--- a/web/app/components/base/agent-log-modal/__tests__/tool-call.spec.tsx
+++ b/web/app/components/base/agent-log-modal/__tests__/tool-call.spec.tsx
@@ -1,8 +1,8 @@
import { fireEvent, render, screen } from '@testing-library/react'
import * as React from 'react'
import { describe, expect, it, vi } from 'vite-plus/test'
+import { useLocale } from '#i18n'
import { BlockEnum } from '@/app/components/workflow/types'
-import { useLocale } from '@/context/i18n'
import ToolCallItem from '../tool-call'
vi.mock('@/app/components/workflow/nodes/_base/components/editor/code-editor', () => ({
@@ -18,7 +18,8 @@ vi.mock('@/app/components/workflow/block-icon', () => ({
default: ({ type }: { type: BlockEnum }) => <div data-testid="block-icon" data-type={type} />,
}))
-vi.mock('@/context/i18n', () => ({
+vi.mock('#i18n', async (importOriginal) => ({
+ ...(await importOriginal<typeof import('#i18n')>()),
useLocale: vi.fn(() => 'en'),
}))
diff --git a/web/app/components/base/agent-log-modal/tool-call.tsx b/web/app/components/base/agent-log-modal/tool-call.tsx
index 5ab968b5efc..7c48a289cab 100644
--- a/web/app/components/base/agent-log-modal/tool-call.tsx
+++ b/web/app/components/base/agent-log-modal/tool-call.tsx
@@ -4,12 +4,12 @@ import type { ToolCall } from '@/models/log'
import { cn } from '@langgenius/dify-ui/cn'
import { RiCheckboxCircleLine, RiErrorWarningLine } from '@remixicon/react'
import { useState } from 'react'
+import { useLocale } from '#i18n'
import { ChevronRight } from '@/app/components/base/icons/src/vender/line/arrows'
import BlockIcon from '@/app/components/workflow/block-icon'
import CodeEditor from '@/app/components/workflow/nodes/_base/components/editor/code-editor'
import { CodeLanguage } from '@/app/components/workflow/nodes/code/types'
import { BlockEnum } from '@/app/components/workflow/types'
-import { useLocale } from '@/context/i18n'
type Props = Readonly<{
toolCall: ToolCall
diff --git a/web/app/components/base/chat/chat/answer/agent-roster-response-content.tsx b/web/app/components/base/chat/chat/answer/agent-roster-response-content.tsx
index d9a372bc9f4..895f5868b78 100644
--- a/web/app/components/base/chat/chat/answer/agent-roster-response-content.tsx
+++ b/web/app/components/base/chat/chat/answer/agent-roster-response-content.tsx
@@ -6,8 +6,7 @@ import { useEffect, useRef, useState } from 'react'
import { useTranslation } from 'react-i18next'
import { FileList } from '@/app/components/base/file-uploader'
import { Markdown } from '@/app/components/base/markdown'
-import { renderI18nObject } from '@/i18n-config'
-import { getLanguage } from '@/i18n-config/language'
+import { getPluginLanguage, renderI18nObject } from '@/i18n-config/metadata'
type AgentRosterResponseContentProps = {
item: ChatItem
@@ -66,7 +65,7 @@ function getToolActivities(
}
} catch {}
- const labelLanguage = getLanguage(language as Locale)
+ const labelLanguage = getPluginLanguage(language as Locale)
return toolNames.filter(Boolean).map((name, index) => ({
kind: SHELL_TOOL_NAMES.has(name) ? 'shell' : 'tool',
diff --git a/web/app/components/base/chat/chat/answer/human-input-content/__tests__/utils.spec.ts b/web/app/components/base/chat/chat/answer/human-input-content/__tests__/utils.spec.ts
index a570ace8083..b41eeec1f0e 100644
--- a/web/app/components/base/chat/chat/answer/human-input-content/__tests__/utils.spec.ts
+++ b/web/app/components/base/chat/chat/answer/human-input-content/__tests__/utils.spec.ts
@@ -1,5 +1,5 @@
import type { FormInputItem } from '@/app/components/workflow/nodes/human-input/types'
-import type { Locale } from '@/i18n-config/language'
+import type { Locale } from '@/i18n-config/locale'
import { UserActionButtonType } from '@/app/components/workflow/nodes/human-input/types'
import { InputVarType, SupportUploadFileTypes } from '@/app/components/workflow/types'
import { TransferMethod } from '@/types/app'
diff --git a/web/app/components/base/chat/chat/answer/human-input-content/expiration-time.tsx b/web/app/components/base/chat/chat/answer/human-input-content/expiration-time.tsx
index 6748de4b2ef..5d0e9bf98fd 100644
--- a/web/app/components/base/chat/chat/answer/human-input-content/expiration-time.tsx
+++ b/web/app/components/base/chat/chat/answer/human-input-content/expiration-time.tsx
@@ -1,7 +1,7 @@
'use client'
import { cn } from '@langgenius/dify-ui/cn'
import { useTranslation } from 'react-i18next'
-import { useLocale } from '@/context/i18n'
+import { useLocale } from '#i18n'
import { getRelativeTime, isRelativeTimeSameOrAfter } from './utils'
type ExpirationTimeProps = {
diff --git a/web/app/components/base/date-and-time-picker/calendar/__tests__/item.spec.tsx b/web/app/components/base/date-and-time-picker/calendar/__tests__/item.spec.tsx
index 22bc6245c2b..5a8f294b9e6 100644
--- a/web/app/components/base/date-and-time-picker/calendar/__tests__/item.spec.tsx
+++ b/web/app/components/base/date-and-time-picker/calendar/__tests__/item.spec.tsx
@@ -14,7 +14,8 @@ vi.mock('react-i18next', async () => {
return createReactI18nextMock(translations)
})
-vi.mock('@/context/i18n', () => ({
+vi.mock('#i18n', async (importOriginal) => ({
+ ...(await importOriginal<typeof import('#i18n')>()),
useLocale: () => locale.value,
}))
diff --git a/web/app/components/base/date-and-time-picker/calendar/item.tsx b/web/app/components/base/date-and-time-picker/calendar/item.tsx
index ec75fbf6575..06b93ca417e 100644
--- a/web/app/components/base/date-and-time-picker/calendar/item.tsx
+++ b/web/app/components/base/date-and-time-picker/calendar/item.tsx
@@ -3,7 +3,7 @@ import type { CalendarItemProps } from '../types'
import { cn } from '@langgenius/dify-ui/cn'
import * as React from 'react'
import { useTranslation } from 'react-i18next'
-import { useLocale } from '@/context/i18n'
+import { useLocale } from '#i18n'
import dayjs from '../utils/dayjs'
const Item: FC<CalendarItemProps> = ({ day, selectedDate, onClick, isDisabled }) => {
diff --git a/web/app/components/base/date-and-time-picker/date-range-picker/index.tsx b/web/app/components/base/date-and-time-picker/date-range-picker/index.tsx
index 6f2ae32f182..5dda95a3117 100644
--- a/web/app/components/base/date-and-time-picker/date-range-picker/index.tsx
+++ b/web/app/components/base/date-and-time-picker/date-range-picker/index.tsx
@@ -7,7 +7,7 @@ import { cn } from '@langgenius/dify-ui/cn'
import { noop } from 'es-toolkit/function'
import * as React from 'react'
import { useTranslation } from 'react-i18next'
-import { useLocale } from '@/context/i18n'
+import { useLocale } from '#i18n'
import { formatToLocalTime } from '@/utils/format'
import DatePicker from '../date-picker'
diff --git a/web/app/components/base/features/new-feature-panel/moderation/__tests__/form-generation.spec.tsx b/web/app/components/base/features/new-feature-panel/moderation/__tests__/form-generation.spec.tsx
index 409ec507395..39a61da434c 100644
--- a/web/app/components/base/features/new-feature-panel/moderation/__tests__/form-generation.spec.tsx
+++ b/web/app/components/base/features/new-feature-panel/moderation/__tests__/form-generation.spec.tsx
@@ -5,7 +5,8 @@ import FormGeneration from '../form-generation'
const { mockLocale } = vi.hoisted(() => ({ mockLocale: { value: 'en-US' } }))
-vi.mock('@/context/i18n', () => ({
+vi.mock('#i18n', async (importOriginal) => ({
+ ...(await importOriginal<typeof import('#i18n')>()),
useLocale: () => mockLocale.value,
}))
diff --git a/web/app/components/base/features/new-feature-panel/moderation/form-generation.tsx b/web/app/components/base/features/new-feature-panel/moderation/form-generation.tsx
index 70e0379930a..a2864177b36 100644
--- a/web/app/components/base/features/new-feature-panel/moderation/form-generation.tsx
+++ b/web/app/components/base/features/new-feature-panel/moderation/form-generation.tsx
@@ -10,7 +10,7 @@ import {
SelectTrigger,
} from '@langgenius/dify-ui/select'
import { Textarea } from '@langgenius/dify-ui/textarea'
-import { useLocale } from '@/context/i18n'
+import { useLocale } from '#i18n'
type FormGenerationProps = {
forms: CodeBasedExtensionForm[]
diff --git a/web/app/components/base/features/new-feature-panel/moderation/index.tsx b/web/app/components/base/features/new-feature-panel/moderation/index.tsx
index 217769fa204..49170c50d6a 100644
--- a/web/app/components/base/features/new-feature-panel/moderation/index.tsx
+++ b/web/app/components/base/features/new-feature-panel/moderation/index.tsx
@@ -4,11 +4,11 @@ import { RiEqualizer2Line } from '@remixicon/react'
import { produce } from 'immer'
import { useCallback, useMemo, useState } from 'react'
import { useTranslation } from 'react-i18next'
+import { useLocale } from '#i18n'
import { useFeatures, useFeaturesStore } from '@/app/components/base/features/hooks'
import FeatureCard from '@/app/components/base/features/new-feature-panel/feature-card'
import { FeatureEnum } from '@/app/components/base/features/types'
import { ContentModeration } from '@/app/components/base/icons/src/vender/features'
-import { useLocale } from '@/context/i18n'
import { useModalContext } from '@/context/modal-context'
import { useCodeBasedExtensions } from '@/service/use-common'
diff --git a/web/app/components/base/features/new-feature-panel/moderation/moderation-setting-modal.tsx b/web/app/components/base/features/new-feature-panel/moderation/moderation-setting-modal.tsx
index f7e968e4395..c42266f16cf 100644
--- a/web/app/components/base/features/new-feature-panel/moderation/moderation-setting-modal.tsx
+++ b/web/app/components/base/features/new-feature-panel/moderation/moderation-setting-modal.tsx
@@ -9,6 +9,7 @@ import { toast } from '@langgenius/dify-ui/toast'
import { useQueryState } from 'nuqs'
import { useCallback, useRef, useState } from 'react'
import { useTranslation } from 'react-i18next'
+import { useLocale } from '#i18n'
import Divider from '@/app/components/base/divider'
import { ApiBasedExtensionSelector } from '@/app/components/header/account-setting/api-based-extension-page/selector'
import { CustomConfigurationStatusEnum } from '@/app/components/header/account-setting/model-provider-page/declarations'
@@ -16,7 +17,7 @@ import {
settingsQueryParamName,
settingsQueryParser,
} from '@/app/components/header/account-setting/query-params'
-import { useDocLink, useLocale } from '@/context/i18n'
+import { useDocLink } from '@/context/i18n'
import { LanguagesSupported } from '@/i18n-config/language'
import { useCodeBasedExtensions, useModelProviderDetails } from '@/service/use-common'
import FormGeneration from './form-generation'
diff --git a/web/app/components/billing/pricing/__tests__/content.spec.tsx b/web/app/components/billing/pricing/__tests__/content.spec.tsx
index bfd90f8ea6e..c216d205ef5 100644
--- a/web/app/components/billing/pricing/__tests__/content.spec.tsx
+++ b/web/app/components/billing/pricing/__tests__/content.spec.tsx
@@ -14,7 +14,14 @@ import { PricingContent } from '../content'
const openBillingWindow = vi.hoisted(() => vi.fn())
vi.mock('@/hooks/use-async-window-open', () => ({ useAsyncWindowOpen: () => openBillingWindow }))
-vi.mock('@/context/i18n', () => ({ useGetLanguage: () => 'en-US', useLocale: () => 'en-US' }))
+vi.mock('@/context/i18n', () => ({
+ useGetLanguage: () => 'en-US',
+}))
+
+vi.mock('#i18n', async (importOriginal) => ({
+ ...(await importOriginal<typeof import('#i18n')>()),
+ useLocale: () => 'en-US',
+}))
vi.mock('../plans/self-hosted-plan-item/list', () => ({ SelfHostedPlanFeatures: () => null }))
vi.mock('@/context/workspace-state', async () => {
const { createWorkspaceStateModuleMock } = await import('@/test/console/state-fixture')
diff --git a/web/app/components/billing/pricing/__tests__/dialog.spec.tsx b/web/app/components/billing/pricing/__tests__/dialog.spec.tsx
index 42b41de60c5..55077399a22 100644
--- a/web/app/components/billing/pricing/__tests__/dialog.spec.tsx
+++ b/web/app/components/billing/pricing/__tests__/dialog.spec.tsx
@@ -13,7 +13,10 @@ vi.mock('../dialog-content', async (importOriginal) => {
return importOriginal()
})
-vi.mock('@/context/i18n', () => ({ useLocale: () => 'en-US' }))
+vi.mock('#i18n', async (importOriginal) => ({
+ ...(await importOriginal<typeof import('#i18n')>()),
+ useLocale: () => 'en-US',
+}))
vi.mock('../content', () => ({
PricingContent: () => (
<>
diff --git a/web/app/components/billing/pricing/__tests__/footer.spec.tsx b/web/app/components/billing/pricing/__tests__/footer.spec.tsx
index e92f5fdf7a6..ea564663d04 100644
--- a/web/app/components/billing/pricing/__tests__/footer.spec.tsx
+++ b/web/app/components/billing/pricing/__tests__/footer.spec.tsx
@@ -1,9 +1,12 @@
-import type { Locale } from '@/i18n-config/language'
+import type { Locale } from '@/i18n-config/locale'
import { render, screen } from '@testing-library/react'
import { PricingFooter } from '../footer'
let locale: Locale = 'en-US'
-vi.mock('@/context/i18n', () => ({ useLocale: () => locale }))
+vi.mock('#i18n', async (importOriginal) => ({
+ ...(await importOriginal<typeof import('#i18n')>()),
+ useLocale: () => locale,
+}))
it.each<[Locale, string]>([
['en-US', ''],
diff --git a/web/app/components/billing/pricing/footer.tsx b/web/app/components/billing/pricing/footer.tsx
index b26fd5d271d..b1f5f4f5652 100644
--- a/web/app/components/billing/pricing/footer.tsx
+++ b/web/app/components/billing/pricing/footer.tsx
@@ -1,6 +1,6 @@
-import type { Locale } from '@/i18n-config/language'
+import type { Locale } from '@/i18n-config/locale'
import { useTranslation } from 'react-i18next'
-import { useLocale } from '@/context/i18n'
+import { useLocale } from '#i18n'
import Link from '@/next/link'
const websiteLocalePaths: Partial<Record<Locale, string>> = {
diff --git a/web/app/components/datasets/access-config/index.tsx b/web/app/components/datasets/access-config/index.tsx
index 3e2fa4e73b8..73602bb9ec0 100644
--- a/web/app/components/datasets/access-config/index.tsx
+++ b/web/app/components/datasets/access-config/index.tsx
@@ -5,10 +5,10 @@ import { useSuspenseQuery } from '@tanstack/react-query'
import { useAtomValue } from 'jotai'
import { useCallback, useMemo, useState } from 'react'
import { useTranslation } from 'react-i18next'
+import { useLocale } from '#i18n'
import AccessRulesEditor from '@/app/components/access-rules-editor'
import Loading from '@/app/components/base/loading'
import { useDatasetDetailContextWithSelector } from '@/context/dataset-detail'
-import { useLocale } from '@/context/i18n'
import { workspacePermissionKeysAtom } from '@/context/permission-state'
import { userProfileQueryOptions } from '@/features/account-profile/client'
import { systemFeaturesQueryOptions } from '@/features/system-features/client'
diff --git a/web/app/components/datasets/create-from-pipeline/list/__tests__/built-in-pipeline-list.spec.tsx b/web/app/components/datasets/create-from-pipeline/list/__tests__/built-in-pipeline-list.spec.tsx
index aedcd265810..442088e11df 100644
--- a/web/app/components/datasets/create-from-pipeline/list/__tests__/built-in-pipeline-list.spec.tsx
+++ b/web/app/components/datasets/create-from-pipeline/list/__tests__/built-in-pipeline-list.spec.tsx
@@ -32,7 +32,8 @@ vi.mock('../template-card', () => ({
// Configurable locale mock
let mockLocale = 'en-US'
-vi.mock('@/context/i18n', () => ({
+vi.mock('#i18n', async (importOriginal) => ({
+ ...(await importOriginal<typeof import('#i18n')>()),
useLocale: () => mockLocale,
}))
diff --git a/web/app/components/datasets/create-from-pipeline/list/built-in-pipeline-list.tsx b/web/app/components/datasets/create-from-pipeline/list/built-in-pipeline-list.tsx
index 749c67aea0d..4b7f346d814 100644
--- a/web/app/components/datasets/create-from-pipeline/list/built-in-pipeline-list.tsx
+++ b/web/app/components/datasets/create-from-pipeline/list/built-in-pipeline-list.tsx
@@ -1,6 +1,6 @@
import { useSuspenseQuery } from '@tanstack/react-query'
import { useMemo } from 'react'
-import { useLocale } from '@/context/i18n'
+import { useLocale } from '#i18n'
import { systemFeaturesQueryOptions } from '@/features/system-features/client'
import { LanguagesSupported } from '@/i18n-config/language'
import { usePipelineTemplateList } from '@/service/use-pipeline'
diff --git a/web/app/components/datasets/create/file-uploader/hooks/use-file-upload.ts b/web/app/components/datasets/create/file-uploader/hooks/use-file-upload.ts
index e85a7ee920d..9da58edbbf4 100644
--- a/web/app/components/datasets/create/file-uploader/hooks/use-file-upload.ts
+++ b/web/app/components/datasets/create/file-uploader/hooks/use-file-upload.ts
@@ -5,8 +5,8 @@ import { toast } from '@langgenius/dify-ui/toast'
import { useSuspenseQuery } from '@tanstack/react-query'
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
import { useTranslation } from 'react-i18next'
+import { useLocale } from '#i18n'
import { getFileUploadErrorMessage } from '@/app/components/base/file-uploader/utils'
-import { useLocale } from '@/context/i18n'
import { systemFeaturesQueryOptions } from '@/features/system-features/client'
import { LanguagesSupported } from '@/i18n-config/language'
import { upload } from '@/service/base'
diff --git a/web/app/components/datasets/create/step-two/index.tsx b/web/app/components/datasets/create/step-two/index.tsx
index ecbb8b0096f..a3b7381be87 100644
--- a/web/app/components/datasets/create/step-two/index.tsx
+++ b/web/app/components/datasets/create/step-two/index.tsx
@@ -6,9 +6,9 @@ import { cn } from '@langgenius/dify-ui/cn'
import { toast } from '@langgenius/dify-ui/toast'
import { useCallback, useEffect, useState } from 'react'
import { useTranslation } from 'react-i18next'
+import { useLocale } from '#i18n'
import Divider from '@/app/components/base/divider'
import { useDatasetDetailContextWithSelector } from '@/context/dataset-detail'
-import { useLocale } from '@/context/i18n'
import useBreakpoints, { MediaType } from '@/hooks/use-breakpoints'
import { LanguagesSupported } from '@/i18n-config/language'
import { DataSourceProvider } from '@/models/common'
diff --git a/web/app/components/datasets/documents/create-from-pipeline/steps/__tests__/step-one-content.spec.tsx b/web/app/components/datasets/documents/create-from-pipeline/steps/__tests__/step-one-content.spec.tsx
index 9772a9ae2b4..d248113c01d 100644
--- a/web/app/components/datasets/documents/create-from-pipeline/steps/__tests__/step-one-content.spec.tsx
+++ b/web/app/components/datasets/documents/create-from-pipeline/steps/__tests__/step-one-content.spec.tsx
@@ -152,8 +152,12 @@ vi.mock('../../data-source/online-drive', () => ({
}))
// Mock locale context
-vi.mock('@/context/i18n', () => ({
+vi.mock('#i18n', async (importOriginal) => ({
+ ...(await importOriginal<typeof import('#i18n')>()),
useLocale: vi.fn(() => 'en'),
+}))
+
+vi.mock('@/context/i18n', () => ({
useDocLink: () => (path: string) => `https://docs.dify.ai${path}`,
}))
diff --git a/web/app/components/datasets/documents/detail/batch-modal/__tests__/csv-downloader.spec.tsx b/web/app/components/datasets/documents/detail/batch-modal/__tests__/csv-downloader.spec.tsx
index 07ff38d0550..0ffc93d4a96 100644
--- a/web/app/components/datasets/documents/detail/batch-modal/__tests__/csv-downloader.spec.tsx
+++ b/web/app/components/datasets/documents/detail/batch-modal/__tests__/csv-downloader.spec.tsx
@@ -7,7 +7,8 @@ import CSVDownload from '../csv-downloader'
// Mock useLocale
let mockLocale = LanguagesSupported[0] // en-US
-vi.mock('@/context/i18n', () => ({
+vi.mock('#i18n', async (importOriginal) => ({
+ ...(await importOriginal<typeof import('#i18n')>()),
useLocale: () => mockLocale,
}))
diff --git a/web/app/components/datasets/documents/detail/batch-modal/csv-downloader.tsx b/web/app/components/datasets/documents/detail/batch-modal/csv-downloader.tsx
index 5f9fd57c1b7..1f18f464437 100644
--- a/web/app/components/datasets/documents/detail/batch-modal/csv-downloader.tsx
+++ b/web/app/components/datasets/documents/detail/batch-modal/csv-downloader.tsx
@@ -3,8 +3,8 @@ import type { FC } from 'react'
import * as React from 'react'
import { useTranslation } from 'react-i18next'
import { useCSVDownloader } from 'react-papaparse'
+import { useLocale } from '#i18n'
import { Download02 as DownloadIcon } from '@/app/components/base/icons/src/vender/solid/general'
-import { useLocale } from '@/context/i18n'
import { LanguagesSupported } from '@/i18n-config/language'
import { ChunkingMode } from '@/models/datasets'
diff --git a/web/app/components/goto-anything/actions/__tests__/plugin.spec.ts b/web/app/components/goto-anything/actions/__tests__/plugin.spec.ts
index bfcc07e3beb..16a0dc946f3 100644
--- a/web/app/components/goto-anything/actions/__tests__/plugin.spec.ts
+++ b/web/app/components/goto-anything/actions/__tests__/plugin.spec.ts
@@ -6,7 +6,8 @@ vi.mock('@/service/marketplace', () => ({
marketplaceQuery: { searchAdvanced: { queryOptions: serviceMocks.queryOptions } },
}))
-vi.mock('@/i18n-config', () => ({
+vi.mock('@/i18n-config/metadata', async (importOriginal) => ({
+ ...(await importOriginal<typeof import('@/i18n-config/metadata')>()),
renderI18nObject: vi.fn((value: Record<string, string> | string, locale: string) =>
typeof value === 'string' ? value : value[locale] || value.en_US || '',
),
diff --git a/web/app/components/goto-anything/actions/commands/__tests__/slash.spec.tsx b/web/app/components/goto-anything/actions/commands/__tests__/slash.spec.tsx
index 79eba4cbde2..90471eebb64 100644
--- a/web/app/components/goto-anything/actions/commands/__tests__/slash.spec.tsx
+++ b/web/app/components/goto-anything/actions/commands/__tests__/slash.spec.tsx
@@ -43,7 +43,7 @@ vi.mock('next-themes', () => ({
setTheme: mockSetTheme,
}),
}))
-vi.mock('@/i18n-config', () => ({
+vi.mock('@/i18n-config/client', () => ({
setLocaleOnClient: mockSetLocale,
}))
vi.mock('@/features/agent-v2/feature-flag', () => ({
diff --git a/web/app/components/goto-anything/actions/commands/slash-provider.tsx b/web/app/components/goto-anything/actions/commands/slash-provider.tsx
index 60f74003288..914bc1ff253 100644
--- a/web/app/components/goto-anything/actions/commands/slash-provider.tsx
+++ b/web/app/components/goto-anything/actions/commands/slash-provider.tsx
@@ -6,7 +6,7 @@ import { ENABLE_FEATURE_PREVIEW } from '@/config'
import { useDocLink } from '@/context/i18n'
import { isCurrentWorkspaceDatasetOperatorAtom } from '@/context/workspace-state'
import { isAgentV2Enabled } from '@/features/agent-v2/feature-flag'
-import { setLocaleOnClient } from '@/i18n-config'
+import { setLocaleOnClient } from '@/i18n-config/client'
import { accountCommand } from './account'
import { createCommand } from './create'
import { discordCommand } from './discord'
diff --git a/web/app/components/goto-anything/actions/plugin.tsx b/web/app/components/goto-anything/actions/plugin.tsx
index 14980fc1691..491afa7b965 100644
--- a/web/app/components/goto-anything/actions/plugin.tsx
+++ b/web/app/components/goto-anything/actions/plugin.tsx
@@ -1,6 +1,6 @@
import type { Plugin } from '../../plugins/types'
import type { ActionItem, PluginSearchResult } from './types'
-import { renderI18nObject } from '@/i18n-config'
+import { renderI18nObject } from '@/i18n-config/metadata'
import { marketplaceQuery } from '@/service/marketplace'
import Icon from '../../plugins/card/base/card-icon'
import { getFormattedPlugin } from '../../plugins/marketplace/utils'
diff --git a/web/app/components/header/account-setting/access-rules-page/permission-set-modal/index.tsx b/web/app/components/header/account-setting/access-rules-page/permission-set-modal/index.tsx
index 958b6b71493..145bb6f7fb7 100644
--- a/web/app/components/header/account-setting/access-rules-page/permission-set-modal/index.tsx
+++ b/web/app/components/header/account-setting/access-rules-page/permission-set-modal/index.tsx
@@ -13,7 +13,8 @@ import { Input } from '@langgenius/dify-ui/input'
import { Textarea } from '@langgenius/dify-ui/textarea'
import { useState } from 'react'
import { useTranslation } from 'react-i18next'
-import { getEnterpriseDocUrl, useLocale } from '@/context/i18n'
+import { useLocale } from '#i18n'
+import { getEnterpriseDocUrl } from '@/context/i18n'
import { getDocLanguage } from '@/i18n-config/language'
import PermissionPicker from './permission-picker'
diff --git a/web/app/components/header/account-setting/access-rules-page/resource-access-rule-section.tsx b/web/app/components/header/account-setting/access-rules-page/resource-access-rule-section.tsx
index 496384a325c..6285cf5503e 100644
--- a/web/app/components/header/account-setting/access-rules-page/resource-access-rule-section.tsx
+++ b/web/app/components/header/account-setting/access-rules-page/resource-access-rule-section.tsx
@@ -8,7 +8,7 @@ import { useInfiniteQuery, useMutation } from '@tanstack/react-query'
import { useAtomValue } from 'jotai'
import { useState } from 'react'
import { useTranslation } from 'react-i18next'
-import { useLocale } from '@/context/i18n'
+import { useLocale } from '#i18n'
import { workspacePermissionKeysAtom } from '@/context/permission-state'
import { getAccessControlTemplateLanguage } from '@/i18n-config/language'
import { consoleQuery } from '@/service/console'
diff --git a/web/app/components/header/account-setting/data-source-page-new/plugin-actions.tsx b/web/app/components/header/account-setting/data-source-page-new/plugin-actions.tsx
index d53bd2d6bdf..6586022adfe 100644
--- a/web/app/components/header/account-setting/data-source-page-new/plugin-actions.tsx
+++ b/web/app/components/header/account-setting/data-source-page-new/plugin-actions.tsx
@@ -5,6 +5,7 @@ import { Button } from '@langgenius/dify-ui/button'
import { Tooltip, TooltipContent, TooltipTrigger } from '@langgenius/dify-ui/tooltip'
import { memo, useId } from 'react'
import { useTranslation } from 'react-i18next'
+import { useLocale } from '#i18n'
import Badge from '@/app/components/base/badge'
import { HeaderModals } from '@/app/components/plugins/plugin-detail-panel/detail-header/components'
import {
@@ -16,7 +17,6 @@ import { usePluginSettingsAccess } from '@/app/components/plugins/plugin-page/us
import { useReadmePanelStore } from '@/app/components/plugins/readme-panel/store'
import { PluginSource } from '@/app/components/plugins/types'
import PluginVersionPicker from '@/app/components/plugins/update-plugin/plugin-version-picker'
-import { useLocale } from '@/context/i18n'
import useTheme from '@/hooks/use-theme'
import { getMarketplaceUrl } from '@/utils/var'
diff --git a/web/app/components/header/account-setting/members-page/index.tsx b/web/app/components/header/account-setting/members-page/index.tsx
index 0c172ce4f27..b76c055545c 100644
--- a/web/app/components/header/account-setting/members-page/index.tsx
+++ b/web/app/components/header/account-setting/members-page/index.tsx
@@ -8,9 +8,9 @@ import { useQuery, useSuspenseQuery } from '@tanstack/react-query'
import { useAtomValue } from 'jotai'
import { useCallback, useState } from 'react'
import { useTranslation } from 'react-i18next'
+import { useLocale } from '#i18n'
import { WorkspaceAvatar } from '@/app/components/base/workspace-avatar'
import UpgradeBtn from '@/app/components/billing/upgrade-btn'
-import { useLocale } from '@/context/i18n'
import { workspacePermissionKeysAtom } from '@/context/permission-state'
import { currentWorkspaceAtom, isCurrentWorkspaceOwnerAtom } from '@/context/workspace-state'
import { userProfileQueryOptions } from '@/features/account-profile/client'
diff --git a/web/app/components/header/account-setting/members-page/invite-modal/index.tsx b/web/app/components/header/account-setting/members-page/invite-modal/index.tsx
index df9137c48d7..3d5d7223694 100644
--- a/web/app/components/header/account-setting/members-page/invite-modal/index.tsx
+++ b/web/app/components/header/account-setting/members-page/invite-modal/index.tsx
@@ -17,7 +17,7 @@ import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
import { useAtomValue } from 'jotai'
import { useState } from 'react'
import { useTranslation } from 'react-i18next'
-import { useLocale } from '@/context/i18n'
+import { useLocale } from '#i18n'
import { deploymentEditionAtom } from '@/features/system-features/state'
import { consoleQuery } from '@/service/console'
import { commonQueryKeys } from '@/service/use-common'
diff --git a/web/app/components/header/account-setting/members-page/invite-modal/role-selector.tsx b/web/app/components/header/account-setting/members-page/invite-modal/role-selector.tsx
index 386947fa7d8..03d3121c3ec 100644
--- a/web/app/components/header/account-setting/members-page/invite-modal/role-selector.tsx
+++ b/web/app/components/header/account-setting/members-page/invite-modal/role-selector.tsx
@@ -17,7 +17,7 @@ import {
} from '@langgenius/dify-ui/select'
import { useCallback, useEffect, useRef, useState } from 'react'
import { useTranslation } from 'react-i18next'
-import { useLocale } from '@/context/i18n'
+import { useLocale } from '#i18n'
import { getAccessControlTemplateLanguage } from '@/i18n-config/language'
import { useWorkspaceRoleList } from '@/service/access-control/use-workspace-roles'
diff --git a/web/app/components/header/account-setting/members-page/member-details-modal/index.tsx b/web/app/components/header/account-setting/members-page/member-details-modal/index.tsx
index e49137259a1..a9cbcd171e6 100644
--- a/web/app/components/header/account-setting/members-page/member-details-modal/index.tsx
+++ b/web/app/components/header/account-setting/members-page/member-details-modal/index.tsx
@@ -7,8 +7,8 @@ import { Dialog, DialogClose, DialogContent, DialogTitle } from '@langgenius/dif
import { IconButton } from '@langgenius/dify-ui/icon-button'
import { memo, useCallback, useMemo, useState } from 'react'
import { useTranslation } from 'react-i18next'
+import { useLocale } from '#i18n'
import Loading from '@/app/components/base/loading'
-import { useLocale } from '@/context/i18n'
import { getAccessControlTemplateLanguage } from '@/i18n-config/language'
import { useRolesOfMember } from '@/service/access-control/use-member-roles'
import AssignRolesModal from '../assign-roles-modal'
diff --git a/web/app/components/header/account-setting/model-provider-page/__tests__/hooks.spec.ts b/web/app/components/header/account-setting/model-provider-page/__tests__/hooks.spec.ts
index 4f6c79c5514..c440fcd6d06 100644
--- a/web/app/components/header/account-setting/model-provider-page/__tests__/hooks.spec.ts
+++ b/web/app/components/header/account-setting/model-provider-page/__tests__/hooks.spec.ts
@@ -8,7 +8,7 @@ import type {
ModelProvider,
} from '../declarations'
import { act, renderHook } from '@testing-library/react'
-import { useLocale } from '@/context/i18n'
+import { useLocale } from '#i18n'
import { fetchDefaultModal } from '@/service/common'
import { consoleQuery } from '@/service/console'
import {
@@ -36,7 +36,8 @@ import {
useUpdateModelProviders,
} from '../hooks'
-vi.mock('@/context/i18n', () => ({
+vi.mock('#i18n', async (importOriginal) => ({
+ ...(await importOriginal<typeof import('#i18n')>()),
useLocale: vi.fn(() => 'en-US'),
}))
diff --git a/web/app/components/header/account-setting/model-provider-page/hooks.ts b/web/app/components/header/account-setting/model-provider-page/hooks.ts
index 73386dc0e69..dfdbf8154d4 100644
--- a/web/app/components/header/account-setting/model-provider-page/hooks.ts
+++ b/web/app/components/header/account-setting/model-provider-page/hooks.ts
@@ -15,13 +15,14 @@ import type {
import type { ModelModalType } from '@/context/modal-context'
import { useQuery, useQueryClient } from '@tanstack/react-query'
import { useCallback, useEffect, useMemo, useState } from 'react'
+import { useLocale } from '#i18n'
import {
useMarketplacePlugins,
useMarketplacePluginsByCollectionId,
} from '@/app/components/plugins/marketplace/hooks'
import { PluginCategoryEnum } from '@/app/components/plugins/types'
-import { useLocale } from '@/context/i18n'
import { useModalContextSelector } from '@/context/modal-context'
+import { getModelLanguage } from '@/i18n-config/metadata'
import { fetchDefaultModal } from '@/service/common'
import { consoleQuery } from '@/service/console'
import { commonQueryKeys, modelProviderDetailsQueryOptions } from '@/service/use-common'
@@ -74,7 +75,7 @@ export const useSystemDefaultModelAndModelList: UseDefaultModelAndModelList = (
export const useLanguage = () => {
const locale = useLocale()
- return locale.replace('-', '_')
+ return getModelLanguage(locale)
}
type ModelQueryOptions = {
diff --git a/web/app/components/header/account-setting/model-provider-page/model-icon/index.tsx b/web/app/components/header/account-setting/model-provider-page/model-icon/index.tsx
index 72f9ea032c5..51925bfcfe1 100644
--- a/web/app/components/header/account-setting/model-provider-page/model-icon/index.tsx
+++ b/web/app/components/header/account-setting/model-provider-page/model-icon/index.tsx
@@ -8,7 +8,7 @@ import type { ModelSelectorProvider } from '../model-selector/types'
import { cn } from '@langgenius/dify-ui/cn'
import { OpenaiYellow } from '@/app/components/base/icons/src/public/llm'
import useTheme from '@/hooks/use-theme'
-import { renderI18nObject } from '@/i18n-config'
+import { renderI18nObject } from '@/i18n-config/metadata'
import { Theme } from '@/types/app'
import { useLanguage } from '../hooks'
diff --git a/web/app/components/header/account-setting/model-provider-page/model-name/__tests__/index.spec.tsx b/web/app/components/header/account-setting/model-provider-page/model-name/__tests__/index.spec.tsx
index 4bde5625748..ba3efd77193 100644
--- a/web/app/components/header/account-setting/model-provider-page/model-name/__tests__/index.spec.tsx
+++ b/web/app/components/header/account-setting/model-provider-page/model-name/__tests__/index.spec.tsx
@@ -10,12 +10,9 @@ import ModelName from '../index'
let mockLocale = 'en-US'
-vi.mock('#i18n', () => ({
- useTranslation: () => ({
- i18n: {
- language: mockLocale,
- },
- }),
+vi.mock('#i18n', async (importOriginal) => ({
+ ...(await importOriginal<typeof import('#i18n')>()),
+ useLocale: () => mockLocale,
}))
const createModelItem = (overrides: Partial<ModelItem> = {}): ModelItem => ({
diff --git a/web/app/components/header/account-setting/model-provider-page/model-name/index.tsx b/web/app/components/header/account-setting/model-provider-page/model-name/index.tsx
index 2616ac7787f..82722aaf5ee 100644
--- a/web/app/components/header/account-setting/model-provider-page/model-name/index.tsx
+++ b/web/app/components/header/account-setting/model-provider-page/model-name/index.tsx
@@ -1,7 +1,7 @@
import type { FC, PropsWithChildren } from 'react'
import type { ModelSelectorModel } from '../model-selector/types'
import { cn } from '@langgenius/dify-ui/cn'
-import { renderI18nObject } from '@/i18n-config'
+import { renderI18nObject } from '@/i18n-config/metadata'
import { useLanguage } from '../hooks'
import ModelBadge from '../model-badge'
import FeatureIcon from '../model-selector/feature-icon'
diff --git a/web/app/components/header/account-setting/model-provider-page/model-selector/popup-item.tsx b/web/app/components/header/account-setting/model-provider-page/model-selector/popup-item.tsx
index a062698c556..c5851f606ab 100644
--- a/web/app/components/header/account-setting/model-provider-page/model-selector/popup-item.tsx
+++ b/web/app/components/header/account-setting/model-provider-page/model-selector/popup-item.tsx
@@ -18,7 +18,7 @@ import { useCallback, useId, useState } from 'react'
import { useTranslation } from 'react-i18next'
import { useModalContext } from '@/context/modal-context'
import { useCredentialPermissions } from '@/hooks/use-credential-permissions'
-import { renderI18nObject } from '@/i18n-config'
+import { renderI18nObject } from '@/i18n-config/metadata'
import { consoleQuery } from '@/service/console'
import { ConfigurationMethodEnum, ModelStatusEnum } from '../declarations'
import {
diff --git a/web/app/components/header/account-setting/model-provider-page/model-selector/popup.tsx b/web/app/components/header/account-setting/model-provider-page/model-selector/popup.tsx
index 0926973969f..95bf0f00191 100644
--- a/web/app/components/header/account-setting/model-provider-page/model-selector/popup.tsx
+++ b/web/app/components/header/account-setting/model-provider-page/model-selector/popup.tsx
@@ -21,7 +21,7 @@ import useRefreshPluginList from '@/app/components/plugins/install-plugin/hooks/
import useWorkspacePluginInstallPermission from '@/app/components/plugins/install-plugin/hooks/use-workspace-plugin-install-permission'
import { PluginCategoryEnum } from '@/app/components/plugins/types'
import { systemFeaturesQueryOptions } from '@/features/system-features/client'
-import { renderI18nObject } from '@/i18n-config'
+import { renderI18nObject } from '@/i18n-config/metadata'
import { consoleQuery } from '@/service/console'
import { fetchPluginInfoFromMarketPlace } from '@/service/plugins'
import { useInstallPackageFromMarketPlace } from '@/service/use-plugins'
diff --git a/web/app/components/header/account-setting/model-provider-page/provider-added-card/index.tsx b/web/app/components/header/account-setting/model-provider-page/provider-added-card/index.tsx
index 3172b4ca4d6..2c0405b2c9f 100644
--- a/web/app/components/header/account-setting/model-provider-page/provider-added-card/index.tsx
+++ b/web/app/components/header/account-setting/model-provider-page/provider-added-card/index.tsx
@@ -12,7 +12,7 @@ import { PluginCategoryEnum } from '@/app/components/plugins/types'
import { workspacePermissionKeysAtom } from '@/context/permission-state'
import { systemFeaturesQueryOptions } from '@/features/system-features/client'
import { useCredentialPermissions } from '@/hooks/use-credential-permissions'
-import { renderI18nObject } from '@/i18n-config'
+import { renderI18nObject } from '@/i18n-config/metadata'
import { consoleQuery } from '@/service/console'
import { commonQueryKeys } from '@/service/use-common'
import { useInvalidateInstalledPluginList } from '@/service/use-plugins'
diff --git a/web/app/components/header/account-setting/model-provider-page/provider-added-card/provider-card-actions.tsx b/web/app/components/header/account-setting/model-provider-page/provider-added-card/provider-card-actions.tsx
index 8eb4fd8edfa..fbee6a9392c 100644
--- a/web/app/components/header/account-setting/model-provider-page/provider-added-card/provider-card-actions.tsx
+++ b/web/app/components/header/account-setting/model-provider-page/provider-added-card/provider-card-actions.tsx
@@ -17,6 +17,7 @@ import { useQueryClient } from '@tanstack/react-query'
import { useBoolean } from 'ahooks'
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
import { useTranslation } from 'react-i18next'
+import { useLocale } from '#i18n'
import Badge from '@/app/components/base/badge'
import { HeaderModals } from '@/app/components/plugins/plugin-detail-panel/detail-header/components'
import {
@@ -27,7 +28,6 @@ import { OperationDropdown } from '@/app/components/plugins/plugin-detail-panel/
import { usePluginSettingsAccess } from '@/app/components/plugins/plugin-page/use-reference-setting'
import { PluginSource } from '@/app/components/plugins/types'
import PluginVersionPicker from '@/app/components/plugins/update-plugin/plugin-version-picker'
-import { useLocale } from '@/context/i18n'
import useTheme from '@/hooks/use-theme'
import { consoleQuery } from '@/service/console'
import { uninstallPlugin } from '@/service/plugins'
diff --git a/web/app/components/header/account-setting/model-provider-page/provider-icon/index.tsx b/web/app/components/header/account-setting/model-provider-page/provider-icon/index.tsx
index 34c9ed68e2e..d46ff856715 100644
--- a/web/app/components/header/account-setting/model-provider-page/provider-icon/index.tsx
+++ b/web/app/components/header/account-setting/model-provider-page/provider-icon/index.tsx
@@ -4,7 +4,7 @@ import { cn } from '@langgenius/dify-ui/cn'
import { AnthropicDark, AnthropicLight } from '@/app/components/base/icons/src/public/llm'
import { Openai } from '@/app/components/base/icons/src/vender/other'
import useTheme from '@/hooks/use-theme'
-import { renderI18nObject } from '@/i18n-config'
+import { renderI18nObject } from '@/i18n-config/metadata'
import { Theme } from '@/types/app'
import { useLanguage } from '../hooks'
diff --git a/web/app/components/header/account-setting/permissions-page/index.tsx b/web/app/components/header/account-setting/permissions-page/index.tsx
index 97995601478..4bc4c3ed268 100644
--- a/web/app/components/header/account-setting/permissions-page/index.tsx
+++ b/web/app/components/header/account-setting/permissions-page/index.tsx
@@ -7,7 +7,7 @@ import { toast } from '@langgenius/dify-ui/toast'
import { useAtomValue } from 'jotai'
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
import { useTranslation } from 'react-i18next'
-import { useLocale } from '@/context/i18n'
+import { useLocale } from '#i18n'
import { workspacePermissionKeysAtom } from '@/context/permission-state'
import { getAccessControlTemplateLanguage } from '@/i18n-config/language'
import {
diff --git a/web/app/components/header/account-setting/permissions-page/role-modal/index.tsx b/web/app/components/header/account-setting/permissions-page/role-modal/index.tsx
index a67ad99d6f0..2d66c4b9ccb 100644
--- a/web/app/components/header/account-setting/permissions-page/role-modal/index.tsx
+++ b/web/app/components/header/account-setting/permissions-page/role-modal/index.tsx
@@ -13,7 +13,8 @@ import { Input } from '@langgenius/dify-ui/input'
import { Textarea } from '@langgenius/dify-ui/textarea'
import { useCallback, useState } from 'react'
import { useTranslation } from 'react-i18next'
-import { getEnterpriseDocUrl, useLocale } from '@/context/i18n'
+import { useLocale } from '#i18n'
+import { getEnterpriseDocUrl } from '@/context/i18n'
import { getDocLanguage } from '@/i18n-config/language'
import PermissionField from './permission-field'
diff --git a/web/app/components/header/account-setting/preference-page/__tests__/index.spec.tsx b/web/app/components/header/account-setting/preference-page/__tests__/index.spec.tsx
index 028ab895c2d..a4f65eebca9 100644
--- a/web/app/components/header/account-setting/preference-page/__tests__/index.spec.tsx
+++ b/web/app/components/header/account-setting/preference-page/__tests__/index.spec.tsx
@@ -25,11 +25,12 @@ vi.mock('@/next/navigation', () => ({
useRouter: () => ({ refresh: mockRefresh }),
}))
-vi.mock('@/context/i18n', () => ({
+vi.mock('#i18n', async (importOriginal) => ({
+ ...(await importOriginal<typeof import('#i18n')>()),
useLocale: () => mockLocale,
}))
-vi.mock('@/i18n-config', () => ({
+vi.mock('@/i18n-config/client', () => ({
setLocaleOnClient: vi.fn(),
}))
diff --git a/web/app/components/header/account-setting/preference-page/index.tsx b/web/app/components/header/account-setting/preference-page/index.tsx
index 689c6054357..494207b55c3 100644
--- a/web/app/components/header/account-setting/preference-page/index.tsx
+++ b/web/app/components/header/account-setting/preference-page/index.tsx
@@ -13,9 +13,9 @@ import { useMutation, useSuspenseQuery } from '@tanstack/react-query'
import { useTheme } from 'next-themes'
import { useState } from 'react'
import { useTranslation } from 'react-i18next'
-import { useLocale } from '@/context/i18n'
+import { useLocale } from '#i18n'
import { userProfileQueryOptions } from '@/features/account-profile/client'
-import { setLocaleOnClient } from '@/i18n-config'
+import { setLocaleOnClient } from '@/i18n-config/client'
import { languages } from '@/i18n-config/language'
import { useRouter } from '@/next/navigation'
import { consoleQuery } from '@/service/console'
diff --git a/web/app/components/header/account-setting/workspace-role-checkbox-list.tsx b/web/app/components/header/account-setting/workspace-role-checkbox-list.tsx
index e5a43efaf8c..52338cb25c2 100644
--- a/web/app/components/header/account-setting/workspace-role-checkbox-list.tsx
+++ b/web/app/components/header/account-setting/workspace-role-checkbox-list.tsx
@@ -13,8 +13,8 @@ import {
} from '@langgenius/dify-ui/scroll-area'
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
import { useTranslation } from 'react-i18next'
+import { useLocale } from '#i18n'
import { SearchInput } from '@/app/components/base/search-input'
-import { useLocale } from '@/context/i18n'
import { getAccessControlTemplateLanguage } from '@/i18n-config/language'
import { useWorkspaceRoleList } from '@/service/access-control/use-workspace-roles'
diff --git a/web/app/components/integrations/tool-provider-card.tsx b/web/app/components/integrations/tool-provider-card.tsx
index 27dc904c968..c22c599a289 100644
--- a/web/app/components/integrations/tool-provider-card.tsx
+++ b/web/app/components/integrations/tool-provider-card.tsx
@@ -8,7 +8,7 @@ import { useTranslation } from 'react-i18next'
import Icon from '@/app/components/plugins/card/base/card-icon'
import CornerMark from '@/app/components/plugins/card/base/corner-mark'
import { useGetLanguage } from '@/context/i18n'
-import { renderI18nObject } from '@/i18n-config'
+import { renderI18nObject } from '@/i18n-config/metadata'
const getCollectionPluginIdentity = (collection: Collection) => {
const [org, ...nameParts] = collection.plugin_id?.split('/').filter(Boolean) ?? []
diff --git a/web/app/components/main-nav/__tests__/index.spec.tsx b/web/app/components/main-nav/__tests__/index.spec.tsx
index d9040ba6e21..f98ae8b8ee0 100644
--- a/web/app/components/main-nav/__tests__/index.spec.tsx
+++ b/web/app/components/main-nav/__tests__/index.spec.tsx
@@ -379,8 +379,12 @@ vi.mock('@/app/components/header/github-star', () => ({
default: ({ className }: { className?: string }) => <span className={className}>1,234</span>,
}))
-vi.mock('@/context/i18n', () => ({
+vi.mock('#i18n', async (importOriginal) => ({
+ ...(await importOriginal<typeof import('#i18n')>()),
useLocale: () => 'en-US',
+}))
+
+vi.mock('@/context/i18n', () => ({
useDocLink: () => (path: string) => `https://docs.dify.ai${path}`,
}))
diff --git a/web/app/components/plugins/card/__tests__/index.spec.tsx b/web/app/components/plugins/card/__tests__/index.spec.tsx
index 31f04b62dd3..669591379d8 100644
--- a/web/app/components/plugins/card/__tests__/index.spec.tsx
+++ b/web/app/components/plugins/card/__tests__/index.spec.tsx
@@ -43,7 +43,8 @@ vi.mock('@/hooks/use-theme', () => ({
default: () => ({ theme: 'light' }),
}))
-vi.mock('@/i18n-config', () => ({
+vi.mock('@/i18n-config/metadata', async (importOriginal) => ({
+ ...(await importOriginal<typeof import('@/i18n-config/metadata')>()),
renderI18nObject: (value: Record<string, string>) => value['en-US'] ?? '',
}))
diff --git a/web/app/components/plugins/card/index.tsx b/web/app/components/plugins/card/index.tsx
index 4a5ebaa6d9f..cdbb6f4304c 100644
--- a/web/app/components/plugins/card/index.tsx
+++ b/web/app/components/plugins/card/index.tsx
@@ -7,7 +7,7 @@ import { useTranslation } from '#i18n'
import { useGetLanguage } from '@/context/i18n'
import { currentWorkspaceIdAtom } from '@/context/workspace-state'
import useTheme from '@/hooks/use-theme'
-import { renderI18nObject } from '@/i18n-config'
+import { renderI18nObject } from '@/i18n-config/metadata'
import { Theme } from '@/types/app'
import { formatNumber } from '@/utils/format'
import Partner from '../base/badges/partner'
diff --git a/web/app/components/plugins/marketplace/__tests__/embedded.spec.tsx b/web/app/components/plugins/marketplace/__tests__/embedded.spec.tsx
index cfec2139e82..ba1b94248bf 100644
--- a/web/app/components/plugins/marketplace/__tests__/embedded.spec.tsx
+++ b/web/app/components/plugins/marketplace/__tests__/embedded.spec.tsx
@@ -6,7 +6,8 @@ import { beforeEach, describe, expect, it, vi } from 'vite-plus/test'
const mockFetchPluginBanners = vi.fn()
-vi.mock('@/context/i18n', () => ({
+vi.mock('#i18n', async (importOriginal) => ({
+ ...(await importOriginal<typeof import('#i18n')>()),
useLocale: () => 'zh-Hans',
}))
diff --git a/web/app/components/plugins/marketplace/embedded.tsx b/web/app/components/plugins/marketplace/embedded.tsx
index 297d6504579..6d7cb486c00 100644
--- a/web/app/components/plugins/marketplace/embedded.tsx
+++ b/web/app/components/plugins/marketplace/embedded.tsx
@@ -3,7 +3,7 @@
import type { PluginBanner } from '@dify/contracts/marketplace'
import type { MarketplaceViewProps } from './view'
import { queryOptions, useQuery } from '@tanstack/react-query'
-import { useLocale } from '@/context/i18n'
+import { useLocale } from '#i18n'
import { useResetMarketplaceSearchModeOnMount } from './atoms'
import { fetchPluginBanners } from './home/banners'
import { MarketplaceView } from './view'
diff --git a/web/app/components/plugins/marketplace/home/marketplace-search-autocomplete.tsx b/web/app/components/plugins/marketplace/home/marketplace-search-autocomplete.tsx
index 3fd90d4366e..39c2345f4cc 100644
--- a/web/app/components/plugins/marketplace/home/marketplace-search-autocomplete.tsx
+++ b/web/app/components/plugins/marketplace/home/marketplace-search-autocomplete.tsx
@@ -25,7 +25,7 @@ import { useDebounce } from 'ahooks'
import { useEffect, useRef, useState } from 'react'
import { useTranslation } from '#i18n'
import { MARKETPLACE_API_PREFIX } from '@/config'
-import { renderI18nObject } from '@/i18n-config/index'
+import { renderI18nObject } from '@/i18n-config/metadata'
import { marketplaceQuery } from '@/service/marketplace'
import { markMarketplaceSiteSearch } from '@/utils/marketplace-site-track'
import {
diff --git a/web/app/components/plugins/marketplace/list/__tests__/list-with-collection-layout.browser.spec.tsx b/web/app/components/plugins/marketplace/list/__tests__/list-with-collection-layout.browser.spec.tsx
index c939c9ea73a..ebc278238a8 100644
--- a/web/app/components/plugins/marketplace/list/__tests__/list-with-collection-layout.browser.spec.tsx
+++ b/web/app/components/plugins/marketplace/list/__tests__/list-with-collection-layout.browser.spec.tsx
@@ -26,8 +26,9 @@ vi.mock('#i18n', async () => {
}
})
-vi.mock('@/i18n-config/language', () => ({
- getLanguage: (locale: string) => locale,
+vi.mock('@/i18n-config/metadata', async (importOriginal) => ({
+ ...(await importOriginal<typeof import('@/i18n-config/metadata')>()),
+ getPluginLanguage: (locale: string) => locale,
}))
vi.mock('../../atoms', () => ({
diff --git a/web/app/components/plugins/marketplace/list/__tests__/list-with-collection.spec.tsx b/web/app/components/plugins/marketplace/list/__tests__/list-with-collection.spec.tsx
index 6cd03ac2bb7..36cf7dae10e 100644
--- a/web/app/components/plugins/marketplace/list/__tests__/list-with-collection.spec.tsx
+++ b/web/app/components/plugins/marketplace/list/__tests__/list-with-collection.spec.tsx
@@ -9,8 +9,9 @@ vi.mock('../../atoms', () => ({
useMarketplaceMoreClick: () => mockMoreClick,
}))
-vi.mock('@/i18n-config/language', () => ({
- getLanguage: (locale: string) => locale,
+vi.mock('@/i18n-config/metadata', async (importOriginal) => ({
+ ...(await importOriginal<typeof import('@/i18n-config/metadata')>()),
+ getPluginLanguage: (locale: string) => locale,
}))
vi.mock('../card-wrapper', () => ({
diff --git a/web/app/components/plugins/marketplace/list/card-wrapper.tsx b/web/app/components/plugins/marketplace/list/card-wrapper.tsx
index d090a11e368..12ac75161fc 100644
--- a/web/app/components/plugins/marketplace/list/card-wrapper.tsx
+++ b/web/app/components/plugins/marketplace/list/card-wrapper.tsx
@@ -11,7 +11,7 @@ import { useTags } from '@/app/components/plugins/hooks'
import { useOptionalPluginInstallPermission } from '@/app/components/plugins/install-plugin/hooks/use-plugin-install-permission'
import InstallFromMarketplace from '@/app/components/plugins/install-plugin/install-from-marketplace'
import { useGetLanguage } from '@/context/i18n'
-import { renderI18nObject } from '@/i18n-config'
+import { renderI18nObject } from '@/i18n-config/metadata'
import Link from '@/next/link'
import { trackMarketplaceSiteCardClick } from '@/utils/marketplace-site-track'
import MarketplaceDetailDialog from '../detail-dialog'
diff --git a/web/app/components/plugins/marketplace/list/list-with-collection.tsx b/web/app/components/plugins/marketplace/list/list-with-collection.tsx
index ecebf4990e2..bc2d75ad941 100644
--- a/web/app/components/plugins/marketplace/list/list-with-collection.tsx
+++ b/web/app/components/plugins/marketplace/list/list-with-collection.tsx
@@ -5,7 +5,7 @@ import type { Plugin } from '@/app/components/plugins/types'
import { cn } from '@langgenius/dify-ui/cn'
import { useEffect, useId, useMemo, useRef, useState } from 'react'
import { useLocale, useTranslation } from '#i18n'
-import { getLanguage } from '@/i18n-config/language'
+import { getPluginLanguage } from '@/i18n-config/metadata'
import { trackMarketplaceSiteEvent } from '@/utils/marketplace-site-track'
import { useMarketplaceMoreClick } from '../atoms'
import { MARKETPLACE_CONTAINER_ID } from '../constants'
@@ -197,7 +197,7 @@ const CollectionSection = ({
isPartnersCollection && styles.partnerTitle,
)}
>
- {collection.label[getLanguage(locale)]}
+ {collection.label[getPluginLanguage(locale)]}
</div>
<div
className={cn(
@@ -207,10 +207,10 @@ const CollectionSection = ({
>
{isPartnersCollection ? (
<span className={styles.partnerDescription}>
- {collection.description[getLanguage(locale)]}
+ {collection.description[getPluginLanguage(locale)]}
</span>
) : (
- collection.description[getLanguage(locale)]
+ collection.description[getPluginLanguage(locale)]
)}
{isPartnersCollection && (
<>
diff --git a/web/app/components/plugins/plugin-detail-panel/detail-header/index.tsx b/web/app/components/plugins/plugin-detail-panel/detail-header/index.tsx
index b0ac3a926c8..c39580dee1a 100644
--- a/web/app/components/plugins/plugin-detail-panel/detail-header/index.tsx
+++ b/web/app/components/plugins/plugin-detail-panel/detail-header/index.tsx
@@ -8,6 +8,7 @@ import { Tooltip, TooltipContent, TooltipTrigger } from '@langgenius/dify-ui/too
import { useQuery } from '@tanstack/react-query'
import { useCallback, useMemo } from 'react'
import { useTranslation } from 'react-i18next'
+import { useLocale } from '#i18n'
import Badge from '@/app/components/base/badge'
import { AuthCategory, PluginAuth } from '@/app/components/plugins/plugin-auth'
import { OperationDropdown } from '@/app/components/plugins/plugin-detail-panel/operation-dropdown'
@@ -15,7 +16,7 @@ import { BUILTIN_TOOLS_ARRAY } from '@/app/components/plugins/readme-panel/const
import { useReadmePanelStore } from '@/app/components/plugins/readme-panel/store'
import PluginVersionPicker from '@/app/components/plugins/update-plugin/plugin-version-picker'
import { API_PREFIX } from '@/config'
-import { useGetLanguage, useLocale } from '@/context/i18n'
+import { useGetLanguage } from '@/context/i18n'
import { userProfileQueryOptions } from '@/features/account-profile/client'
import useTheme from '@/hooks/use-theme'
import { useAllToolProviders } from '@/service/use-tools'
diff --git a/web/app/components/plugins/plugin-detail-panel/strategy-detail.tsx b/web/app/components/plugins/plugin-detail-panel/strategy-detail.tsx
index a020e5dfec5..8986c4a81f0 100644
--- a/web/app/components/plugins/plugin-detail-panel/strategy-detail.tsx
+++ b/web/app/components/plugins/plugin-detail-panel/strategy-detail.tsx
@@ -1,7 +1,9 @@
'use client'
+
import type { FC } from 'react'
import type { StrategyDetail as StrategyDetailType } from '@/app/components/plugins/types'
-import type { Locale } from '@/i18n-config'
+import type { Locale } from '@/i18n-config/locale'
+import type { PluginLanguage } from '@/i18n-config/metadata'
import { cn } from '@langgenius/dify-ui/cn'
import {
Drawer,
@@ -26,10 +28,10 @@ type Props = Readonly<{
provider: {
author: string
name: string
- description: Record<Locale, string>
+ description: Record<Locale | PluginLanguage, string>
tenant_id: string
icon: string
- label: Record<Locale, string>
+ label: Record<Locale | PluginLanguage, string>
tags: string[]
}
detail: StrategyDetailType
diff --git a/web/app/components/plugins/plugin-detail-panel/strategy-item.tsx b/web/app/components/plugins/plugin-detail-panel/strategy-item.tsx
index f25ef995c6b..89f4e56d1ae 100644
--- a/web/app/components/plugins/plugin-detail-panel/strategy-item.tsx
+++ b/web/app/components/plugins/plugin-detail-panel/strategy-item.tsx
@@ -1,6 +1,8 @@
'use client'
+
import type { StrategyDetail } from '@/app/components/plugins/types'
-import type { Locale } from '@/i18n-config'
+import type { Locale } from '@/i18n-config/locale'
+import type { PluginLanguage } from '@/i18n-config/metadata'
import { cn } from '@langgenius/dify-ui/cn'
import * as React from 'react'
import { useState } from 'react'
@@ -11,10 +13,10 @@ type Props = Readonly<{
provider: {
author: string
name: string
- description: Record<Locale, string>
+ description: Record<Locale | PluginLanguage, string>
tenant_id: string
icon: string
- label: Record<Locale, string>
+ label: Record<Locale | PluginLanguage, string>
tags: string[]
}
detail: StrategyDetail
diff --git a/web/app/components/plugins/plugin-mutation-model/__tests__/index.spec.tsx b/web/app/components/plugins/plugin-mutation-model/__tests__/index.spec.tsx
index 3999c178375..ea107adca89 100644
--- a/web/app/components/plugins/plugin-mutation-model/__tests__/index.spec.tsx
+++ b/web/app/components/plugins/plugin-mutation-model/__tests__/index.spec.tsx
@@ -18,14 +18,12 @@ vi.mock('@/hooks/use-theme', () => ({
default: () => ({ theme: 'light' }),
}))
-vi.mock('@/i18n-config', () => ({
+vi.mock('@/i18n-config/metadata', async (importOriginal) => ({
+ ...(await importOriginal<typeof import('@/i18n-config/metadata')>()),
renderI18nObject: (obj: Record<string, string>, locale: string) => {
return obj?.[locale] || obj?.['en-US'] || ''
},
-}))
-
-vi.mock('@/i18n-config/language', () => ({
- getLanguage: (locale: string) => locale || 'en-US',
+ getPluginLanguage: (locale: string) => locale || 'en-US',
}))
const mockCategoriesMap: Record<string, { label: string }> = {
diff --git a/web/app/components/plugins/plugin-page/__tests__/plugins-panel.spec.tsx b/web/app/components/plugins/plugin-page/__tests__/plugins-panel.spec.tsx
index c4b14947809..7e25eae1328 100644
--- a/web/app/components/plugins/plugin-page/__tests__/plugins-panel.spec.tsx
+++ b/web/app/components/plugins/plugin-page/__tests__/plugins-panel.spec.tsx
@@ -42,7 +42,8 @@ vi.mock('@tanstack/react-query', () => ({
queryOptions: (options: unknown) => options,
useSuspenseQuery: () => ({ data: mockSystemFeatures.enableMarketplace }),
}))
-vi.mock('@/i18n-config', () => ({
+vi.mock('@/i18n-config/metadata', async (importOriginal) => ({
+ ...(await importOriginal<typeof import('@/i18n-config/metadata')>()),
renderI18nObject: (value: Record<string, string>, locale: string) => value[locale] || '',
}))
diff --git a/web/app/components/plugins/plugin-page/plugin-tasks/components/error-plugin-item.tsx b/web/app/components/plugins/plugin-page/plugin-tasks/components/error-plugin-item.tsx
index 3458b24975b..f7db5146a8d 100644
--- a/web/app/components/plugins/plugin-page/plugin-tasks/components/error-plugin-item.tsx
+++ b/web/app/components/plugins/plugin-page/plugin-tasks/components/error-plugin-item.tsx
@@ -1,6 +1,6 @@
import type { FC } from 'react'
import type { Plugin, PluginStatus } from '@/app/components/plugins/types'
-import type { Locale } from '@/i18n-config'
+import type { PluginLanguage } from '@/i18n-config/metadata'
import { Button } from '@langgenius/dify-ui/button'
import { useCallback, useState } from 'react'
import { useTranslation } from 'react-i18next'
@@ -14,7 +14,7 @@ import PluginItem from './plugin-item'
type ErrorPluginItemProps = {
plugin: PluginStatus
getIconUrl: (icon: string) => string
- language: Locale
+ language: PluginLanguage
onClear: () => void
}
diff --git a/web/app/components/plugins/plugin-page/plugin-tasks/components/plugin-item.tsx b/web/app/components/plugins/plugin-page/plugin-tasks/components/plugin-item.tsx
index b3602f351a4..532036044d9 100644
--- a/web/app/components/plugins/plugin-page/plugin-tasks/components/plugin-item.tsx
+++ b/web/app/components/plugins/plugin-page/plugin-tasks/components/plugin-item.tsx
@@ -1,13 +1,13 @@
import type { FC, ReactNode } from 'react'
import type { PluginStatus } from '@/app/components/plugins/types'
-import type { Locale } from '@/i18n-config'
+import type { PluginLanguage } from '@/i18n-config/metadata'
import { MagicBox } from '@/app/components/base/icons/src/vender/solid/mediaAndDevices'
import CardIcon from '@/app/components/plugins/card/base/card-icon'
type PluginItemProps = {
plugin: PluginStatus
getIconUrl: (icon: string) => string
- language: Locale
+ language: PluginLanguage
statusIcon: ReactNode
statusText: ReactNode
statusClassName?: string
diff --git a/web/app/components/plugins/plugin-page/plugin-tasks/components/plugin-section.tsx b/web/app/components/plugins/plugin-page/plugin-tasks/components/plugin-section.tsx
index d201385be4d..c20c31ccc9a 100644
--- a/web/app/components/plugins/plugin-page/plugin-tasks/components/plugin-section.tsx
+++ b/web/app/components/plugins/plugin-page/plugin-tasks/components/plugin-section.tsx
@@ -1,6 +1,6 @@
import type { ReactNode } from 'react'
import type { PluginStatus } from '@/app/components/plugins/types'
-import type { Locale } from '@/i18n-config'
+import type { PluginLanguage } from '@/i18n-config/metadata'
import {
ScrollArea,
ScrollAreaContent,
@@ -15,7 +15,7 @@ type PluginSectionProps = {
count: number
plugins: PluginStatus[]
getIconUrl: (icon: string) => string
- language: Locale
+ language: PluginLanguage
statusIcon: ReactNode
defaultStatusText: ReactNode
statusClassName?: string
diff --git a/web/app/components/plugins/plugin-page/plugins-panel-utils.ts b/web/app/components/plugins/plugin-page/plugins-panel-utils.ts
index 047114cd793..b5a3c6b8f4d 100644
--- a/web/app/components/plugins/plugin-page/plugins-panel-utils.ts
+++ b/web/app/components/plugins/plugin-page/plugins-panel-utils.ts
@@ -1,5 +1,5 @@
import type { Collection } from '@/app/components/tools/types'
-import { renderI18nObject } from '@/i18n-config'
+import { renderI18nObject } from '@/i18n-config/metadata'
export const EMPTY_BUILTIN_TOOLS: Collection[] = []
diff --git a/web/app/components/plugins/plugin-page/plugins-panel.tsx b/web/app/components/plugins/plugin-page/plugins-panel.tsx
index 411204145fb..88b423f6a83 100644
--- a/web/app/components/plugins/plugin-page/plugins-panel.tsx
+++ b/web/app/components/plugins/plugin-page/plugins-panel.tsx
@@ -14,7 +14,7 @@ import { STEP_BY_STEP_TOUR_TARGETS } from '@/app/components/step-by-step-tour/ta
import ProviderDetail from '@/app/components/tools/provider/detail'
import { useGetLanguage } from '@/context/i18n'
import { systemFeaturesQueryOptions } from '@/features/system-features/client'
-import { renderI18nObject } from '@/i18n-config'
+import { renderI18nObject } from '@/i18n-config/metadata'
import {
normalizePluginCategoryListLanguage,
useInstalledPluginList,
diff --git a/web/app/components/plugins/provider-card.tsx b/web/app/components/plugins/provider-card.tsx
index cdd8581541f..c5acd60e045 100644
--- a/web/app/components/plugins/provider-card.tsx
+++ b/web/app/components/plugins/provider-card.tsx
@@ -8,10 +8,10 @@ import { useTheme } from 'next-themes'
import * as React from 'react'
import { useMemo } from 'react'
import { useTranslation } from 'react-i18next'
+import { useLocale } from '#i18n'
import usePluginInstallPermission from '@/app/components/plugins/install-plugin/hooks/use-plugin-install-permission'
import InstallFromMarketplace from '@/app/components/plugins/install-plugin/install-from-marketplace'
import { getPluginLinkInMarketplace } from '@/app/components/plugins/marketplace/utils'
-import { useLocale } from '@/context/i18n'
import { useRenderI18nObject } from '@/hooks/use-i18n'
import Badge from '../base/badge'
import Icon from './card/base/card-icon'
diff --git a/web/app/components/plugins/reference-setting-modal/auto-update-setting/__tests__/tool-item.spec.tsx b/web/app/components/plugins/reference-setting-modal/auto-update-setting/__tests__/tool-item.spec.tsx
index 9ccb68f7dc6..6b60659ba21 100644
--- a/web/app/components/plugins/reference-setting-modal/auto-update-setting/__tests__/tool-item.spec.tsx
+++ b/web/app/components/plugins/reference-setting-modal/auto-update-setting/__tests__/tool-item.spec.tsx
@@ -6,7 +6,8 @@ import ToolItem from '../tool-item'
vi.mock('@/config', () => ({
MARKETPLACE_API_PREFIX: 'https://marketplace.example.com',
}))
-vi.mock('@/i18n-config', () => ({
+vi.mock('@/i18n-config/metadata', async (importOriginal) => ({
+ ...(await importOriginal<typeof import('@/i18n-config/metadata')>()),
renderI18nObject: (value: Record<string, string>, language: string) => value[language],
}))
diff --git a/web/app/components/plugins/reference-setting-modal/auto-update-setting/tool-item.tsx b/web/app/components/plugins/reference-setting-modal/auto-update-setting/tool-item.tsx
index dce950c0496..b78456767e1 100644
--- a/web/app/components/plugins/reference-setting-modal/auto-update-setting/tool-item.tsx
+++ b/web/app/components/plugins/reference-setting-modal/auto-update-setting/tool-item.tsx
@@ -6,7 +6,7 @@ import * as React from 'react'
import Icon from '@/app/components/plugins/card/base/card-icon'
import { MARKETPLACE_API_PREFIX } from '@/config'
import { useGetLanguage } from '@/context/i18n'
-import { renderI18nObject } from '@/i18n-config'
+import { renderI18nObject } from '@/i18n-config/metadata'
type Props = Readonly<{
payload: PluginDetail
diff --git a/web/app/components/plugins/types.ts b/web/app/components/plugins/types.ts
index d68e9ffce8b..86888865192 100644
--- a/web/app/components/plugins/types.ts
+++ b/web/app/components/plugins/types.ts
@@ -3,7 +3,8 @@ import type { CredentialFormSchemaBase } from '../header/account-setting/model-p
import type { AutoUpdateConfig } from './reference-setting-modal/auto-update-setting/types'
import type { TypeWithI18N } from '@/app/components/base/form/types'
import type { ToolCredential } from '@/app/components/tools/types'
-import type { Locale } from '@/i18n-config'
+import type { Locale } from '@/i18n-config/locale'
+import type { PluginLanguage } from '@/i18n-config/metadata'
export enum PluginCategoryEnum {
tool = 'tool',
@@ -25,9 +26,9 @@ type PluginToolDeclaration = {
identity: {
author: string
name: string
- description: Record<Locale, string>
+ description: Record<Locale | PluginLanguage, string>
icon: string
- label: Record<Locale, string>
+ label: Record<Locale | PluginLanguage, string>
tags: string[]
}
credentials_schema: ToolCredential[] // TODO
@@ -73,8 +74,8 @@ export type PluginDeclaration = {
icon_dark?: string
name: string
category: PluginCategoryEnum
- label: Record<Locale, string>
- description: Record<Locale, string>
+ label: Record<Locale | PluginLanguage, string>
+ description: Record<Locale | PluginLanguage, string>
created_at: string
resource: any // useless in frontend
plugins: any // useless in frontend
@@ -104,16 +105,16 @@ type PluginTriggerDefinition = {
type CredentialsSchema = {
name: string
- label: Record<Locale, string>
- description: Record<Locale, string>
+ label: Record<Locale | PluginLanguage, string>
+ description: Record<Locale | PluginLanguage, string>
type: FormTypeEnum
scope: any
required: boolean
default: any
options: any
- help: Record<Locale, string>
+ help: Record<Locale | PluginLanguage, string>
url: string
- placeholder: Record<Locale, string>
+ placeholder: Record<Locale | PluginLanguage, string>
}
type OauthSchema = {
@@ -123,7 +124,7 @@ type OauthSchema = {
export type ParametersSchema = {
name: string
- label: Record<Locale, string>
+ label: Record<Locale | PluginLanguage, string>
type: FormTypeEnum
auto_generate: any
template: any
@@ -136,10 +137,10 @@ export type ParametersSchema = {
precision: any
options?: Array<{
value: string
- label: Record<Locale, string>
+ label: Record<Locale | PluginLanguage, string>
icon?: string
}>
- description: Record<Locale, string>
+ description: Record<Locale | PluginLanguage, string>
}
export type TriggerEventParameter = {
@@ -181,11 +182,11 @@ export type PluginManifestInMarket = {
name: string
org: string
icon: string
- label: Record<Locale, string>
+ label: Record<Locale | PluginLanguage, string>
category: PluginCategoryEnum
version: string // combine the other place to it
latest_version: string
- brief: Record<Locale, string>
+ brief: Record<Locale | PluginLanguage, string>
introduction: string
verified: boolean
install_count: number
@@ -244,9 +245,9 @@ export type Plugin = {
icon: string
icon_dark?: string
verified: boolean
- label: Partial<Record<Locale, string>>
- brief: Partial<Record<Locale, string>>
- description: Partial<Record<Locale, string>>
+ label: Partial<Record<Locale | PluginLanguage, string>>
+ brief: Partial<Record<Locale | PluginLanguage, string>>
+ description: Partial<Record<Locale | PluginLanguage, string>>
// Repo readme.md content
introduction: string
repository: string
@@ -413,7 +414,7 @@ export type PluginStatus = {
status: TaskStatus
message: string
icon: string
- labels: Record<Locale, string>
+ labels: Record<Locale | PluginLanguage, string>
taskId: string
}
@@ -495,9 +496,9 @@ export type VersionProps = {
export type StrategyParamItem = {
name: string
- label: Record<Locale, string>
- help: Record<Locale, string>
- placeholder: Record<Locale, string>
+ label: Record<Locale | PluginLanguage, string>
+ help: Record<Locale | PluginLanguage, string>
+ placeholder: Record<Locale | PluginLanguage, string>
type: string
scope: string
required: boolean
@@ -516,11 +517,11 @@ export type StrategyDetail = {
author: string
name: string
icon: string
- label: Record<Locale, string>
+ label: Record<Locale | PluginLanguage, string>
provider: string
}
parameters: StrategyParamItem[]
- description: Record<Locale, string>
+ description: Record<Locale | PluginLanguage, string>
output_schema: Record<string, any>
features: AgentFeature[]
}
@@ -534,8 +535,8 @@ type AgentFeature = (typeof AgentFeature)[keyof typeof AgentFeature]
type Identity = {
author: string
name: string
- label: Record<Locale, string>
- description: Record<Locale, string>
+ label: Record<Locale | PluginLanguage, string>
+ description: Record<Locale | PluginLanguage, string>
icon: string
icon_dark?: string
tags: string[]
diff --git a/web/app/components/tools/edit-custom-collection-modal/test-api.tsx b/web/app/components/tools/edit-custom-collection-modal/test-api.tsx
index bcf0f5148ca..b70cf260e92 100644
--- a/web/app/components/tools/edit-custom-collection-modal/test-api.tsx
+++ b/web/app/components/tools/edit-custom-collection-modal/test-api.tsx
@@ -22,9 +22,9 @@ import { RiSettings2Line } from '@remixicon/react'
import * as React from 'react'
import { useId, useState } from 'react'
import { useTranslation } from 'react-i18next'
+import { useLocale } from '#i18n'
import { AuthType } from '@/app/components/tools/types'
-import { useLocale } from '@/context/i18n'
-import { getLanguage } from '@/i18n-config/language'
+import { getPluginLanguage } from '@/i18n-config/metadata'
import { testAPIAvailable } from '@/service/tools'
import ConfigCredentials from './config-credentials'
@@ -39,7 +39,7 @@ const TestApi: FC<Props> = ({ positionCenter, customCollection, tool, onHide })
const { t } = useTranslation()
const parameterId = useId()
const locale = useLocale()
- const language = getLanguage(locale)
+ const language = getPluginLanguage(locale)
const [credentialsModalShow, setCredentialsModalShow] = useState(false)
const [tempCredential, setTempCredential] = React.useState<Credential>(
customCollection.credentials,
diff --git a/web/app/components/tools/mcp/detail/tool-item.tsx b/web/app/components/tools/mcp/detail/tool-item.tsx
index c618ce39b2a..a0659a99518 100644
--- a/web/app/components/tools/mcp/detail/tool-item.tsx
+++ b/web/app/components/tools/mcp/detail/tool-item.tsx
@@ -4,8 +4,8 @@ import { cn } from '@langgenius/dify-ui/cn'
import { Popover, PopoverContent, PopoverTrigger } from '@langgenius/dify-ui/popover'
import * as React from 'react'
import { useTranslation } from 'react-i18next'
-import { useLocale } from '@/context/i18n'
-import { getLanguage } from '@/i18n-config/language'
+import { useLocale } from '#i18n'
+import { getPluginLanguage } from '@/i18n-config/metadata'
type Props = Readonly<{
tool: Tool
@@ -13,7 +13,7 @@ type Props = Readonly<{
const MCPToolItem = ({ tool }: Props) => {
const locale = useLocale()
- const language = getLanguage(locale)
+ const language = getPluginLanguage(locale)
const { t } = useTranslation()
const renderParameters = () => {
diff --git a/web/app/components/tools/provider/__tests__/custom-create-card.spec.tsx b/web/app/components/tools/provider/__tests__/custom-create-card.spec.tsx
index 6e0ba278ec0..4928aa38b4a 100644
--- a/web/app/components/tools/provider/__tests__/custom-create-card.spec.tsx
+++ b/web/app/components/tools/provider/__tests__/custom-create-card.spec.tsx
@@ -18,15 +18,20 @@ vi.mock('@/context/permission-state', async () => {
})
// Mock useLocale and useDocLink
-vi.mock('@/context/i18n', () => ({
+vi.mock('#i18n', async (importOriginal) => ({
+ ...(await importOriginal<typeof import('#i18n')>()),
useLocale: () => 'en-US',
+}))
+
+vi.mock('@/context/i18n', () => ({
useDocLink: () => (path?: string) =>
`https://docs.dify.ai/en${path?.startsWith('/use-dify/') ? `/cloud${path}` : path || ''}`,
}))
-// Mock getLanguage
-vi.mock('@/i18n-config/language', () => ({
- getLanguage: () => 'en-US',
+// Mock getPluginLanguage
+vi.mock('@/i18n-config/metadata', async (importOriginal) => ({
+ ...(await importOriginal<typeof import('@/i18n-config/metadata')>()),
+ getPluginLanguage: () => 'en-US',
}))
// Mock createCustomCollection service
diff --git a/web/app/components/tools/provider/__tests__/detail.spec.tsx b/web/app/components/tools/provider/__tests__/detail.spec.tsx
index a5b21a1acb7..ae93482e93e 100644
--- a/web/app/components/tools/provider/__tests__/detail.spec.tsx
+++ b/web/app/components/tools/provider/__tests__/detail.spec.tsx
@@ -48,8 +48,9 @@ const render = (ui: ReactElement) => {
return renderWithConsoleQuery(ui, { queryClient })
}
-vi.mock('@/i18n-config/language', () => ({
- getLanguage: () => 'en_US',
+vi.mock('@/i18n-config/metadata', async (importOriginal) => ({
+ ...(await importOriginal<typeof import('@/i18n-config/metadata')>()),
+ getPluginLanguage: () => 'en_US',
}))
const mockConsoleState = vi.hoisted(() => ({
diff --git a/web/app/components/tools/provider/__tests__/tool-item.spec.tsx b/web/app/components/tools/provider/__tests__/tool-item.spec.tsx
index 48dbf7d67b8..0b11a7fb5f1 100644
--- a/web/app/components/tools/provider/__tests__/tool-item.spec.tsx
+++ b/web/app/components/tools/provider/__tests__/tool-item.spec.tsx
@@ -4,7 +4,10 @@ import userEvent from '@testing-library/user-event'
import { describe, expect, it, vi } from 'vite-plus/test'
import ToolItem from '../tool-item'
-vi.mock('@/i18n-config/language', () => ({ getLanguage: () => 'en_US' }))
+vi.mock('@/i18n-config/metadata', async (importOriginal) => ({
+ ...(await importOriginal<typeof import('@/i18n-config/metadata')>()),
+ getPluginLanguage: () => 'en_US',
+}))
vi.mock(
'@/app/components/app/configuration/config/agent/agent-tools/setting-built-in-tool',
() => ({
diff --git a/web/app/components/tools/provider/detail.tsx b/web/app/components/tools/provider/detail.tsx
index 44f16041351..a26fcadd0bf 100644
--- a/web/app/components/tools/provider/detail.tsx
+++ b/web/app/components/tools/provider/detail.tsx
@@ -34,6 +34,7 @@ import { useQuery, useQueryClient } from '@tanstack/react-query'
import * as React from 'react'
import { useCallback, useEffect, useState } from 'react'
import { useTranslation } from 'react-i18next'
+import { useLocale } from '#i18n'
import Loading from '@/app/components/base/loading'
import { ConfigurationMethodEnum } from '@/app/components/header/account-setting/model-provider-page/declarations'
import Icon from '@/app/components/plugins/card/base/card-icon'
@@ -44,10 +45,9 @@ import EditCustomToolModal from '@/app/components/tools/edit-custom-collection-m
import { useCanManageTools } from '@/app/components/tools/hooks/use-tool-permissions'
import ConfigCredential from '@/app/components/tools/setting/build-in/config-credentials'
import { WorkflowToolDrawer } from '@/app/components/tools/workflow-tool'
-import { useLocale } from '@/context/i18n'
import { useModalContext } from '@/context/modal-context'
import { useCredentialPermissions } from '@/hooks/use-credential-permissions'
-import { getLanguage } from '@/i18n-config/language'
+import { getPluginLanguage } from '@/i18n-config/metadata'
import { consoleQuery } from '@/service/console'
import {
deleteWorkflowTool,
@@ -77,7 +77,7 @@ type Props = Readonly<{
const ProviderDetail = ({ collection, onHide, onRefreshData }: Props) => {
const { t } = useTranslation()
const locale = useLocale()
- const language = getLanguage(locale)
+ const language = getPluginLanguage(locale)
const needAuth = collection.allow_delete || collection.type === CollectionType.model
const isAuthed = collection.is_team_authorization
diff --git a/web/app/components/tools/provider/tool-item.tsx b/web/app/components/tools/provider/tool-item.tsx
index ee1d91377c7..a226c1ad003 100644
--- a/web/app/components/tools/provider/tool-item.tsx
+++ b/web/app/components/tools/provider/tool-item.tsx
@@ -3,9 +3,9 @@ import type { Collection, Tool } from '../types'
import { cn } from '@langgenius/dify-ui/cn'
import * as React from 'react'
import { useState } from 'react'
+import { useLocale } from '#i18n'
import SettingBuiltInTool from '@/app/components/app/configuration/config/agent/agent-tools/setting-built-in-tool'
-import { useLocale } from '@/context/i18n'
-import { getLanguage } from '@/i18n-config/language'
+import { getPluginLanguage } from '@/i18n-config/metadata'
type Props = Readonly<{
disabled?: boolean
@@ -17,7 +17,7 @@ type Props = Readonly<{
const ToolItem = ({ disabled, collection, tool, isBuiltIn, isModel }: Props) => {
const locale = useLocale()
- const language = getLanguage(locale)
+ const language = getPluginLanguage(locale)
const [showDetail, setShowDetail] = useState(false)
return (
diff --git a/web/app/components/workflow/block-selector/__tests__/all-start-blocks.spec.tsx b/web/app/components/workflow/block-selector/__tests__/all-start-blocks.spec.tsx
index ecb901cc0e6..3559ad12f2a 100644
--- a/web/app/components/workflow/block-selector/__tests__/all-start-blocks.spec.tsx
+++ b/web/app/components/workflow/block-selector/__tests__/all-start-blocks.spec.tsx
@@ -2,11 +2,12 @@ import type { ReactElement } from 'react'
import type { TriggerWithProvider } from '../types'
import { fireEvent, screen, waitFor } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
+import { useLocale } from '#i18n'
import { useMarketplacePlugins } from '@/app/components/plugins/marketplace/query'
import { PluginCategoryEnum } from '@/app/components/plugins/types'
import { CollectionType } from '@/app/components/tools/types'
import { useAvailableNodesMetaData } from '@/app/components/workflow-app/hooks/use-available-nodes-meta-data'
-import { useGetLanguage, useLocale } from '@/context/i18n'
+import { useGetLanguage } from '@/context/i18n'
import useTheme from '@/hooks/use-theme'
import { useFeaturedTriggersRecommendations } from '@/service/use-plugins'
import { useAllTriggerPlugins, useInvalidateAllTriggerPlugins } from '@/service/use-triggers'
@@ -19,6 +20,10 @@ import { createPlugin } from './factories'
vi.mock('@/context/i18n', () => ({
useGetLanguage: vi.fn(),
+}))
+
+vi.mock('#i18n', async (importOriginal) => ({
+ ...(await importOriginal<typeof import('#i18n')>()),
useLocale: vi.fn(),
}))
@@ -180,7 +185,7 @@ describe('AllStartBlocks', () => {
vi.clearAllMocks()
enableMarketplaceForRender = false
mockUseGetLanguage.mockReturnValue('en_US')
- mockUseLocale.mockReturnValue('en_US')
+ mockUseLocale.mockReturnValue('en-US')
mockUseTheme.mockReturnValue({ theme: Theme.light } as ReturnType<typeof useTheme>)
mockUseMarketplacePlugins.mockReturnValue(createMarketplacePluginsMock())
mockUseAllTriggerPlugins.mockReturnValue(
diff --git a/web/app/components/workflow/block-selector/featured-tools.tsx b/web/app/components/workflow/block-selector/featured-tools.tsx
index 634659b60d7..5033200444c 100644
--- a/web/app/components/workflow/block-selector/featured-tools.tsx
+++ b/web/app/components/workflow/block-selector/featured-tools.tsx
@@ -4,7 +4,7 @@ import type { TFunction } from 'i18next'
import type { ToolWithProvider } from '../types'
import type { ToolDefaultValue, ToolValue } from './types'
import type { Plugin } from '@/app/components/plugins/types'
-import type { Locale } from '@/i18n-config'
+import type { PluginLanguage } from '@/i18n-config/metadata'
import { Button } from '@langgenius/dify-ui/button'
import { cn } from '@langgenius/dify-ui/cn'
import { Collapsible, CollapsiblePanel, CollapsibleTrigger } from '@langgenius/dify-ui/collapsible'
@@ -236,7 +236,7 @@ const FeaturedTools = ({
type FeaturedToolUninstalledItemProps = {
plugin: Plugin
- language: Locale
+ language: PluginLanguage
previewCardHandle: PreviewCardHandle<FeaturedToolPreviewPayload>
onInstallSuccess?: () => Promise<void> | void
t: TFunction
diff --git a/web/app/components/workflow/block-selector/featured-triggers.tsx b/web/app/components/workflow/block-selector/featured-triggers.tsx
index 73a318c0545..edc21899a38 100644
--- a/web/app/components/workflow/block-selector/featured-triggers.tsx
+++ b/web/app/components/workflow/block-selector/featured-triggers.tsx
@@ -4,7 +4,7 @@ import type { TFunction } from 'i18next'
import type { TriggerPluginActionPreviewPayload } from './trigger-plugin/action-item'
import type { TriggerDefaultValue, TriggerWithProvider } from './types'
import type { Plugin } from '@/app/components/plugins/types'
-import type { Locale } from '@/i18n-config'
+import type { PluginLanguage } from '@/i18n-config/metadata'
import { Button } from '@langgenius/dify-ui/button'
import { cn } from '@langgenius/dify-ui/cn'
import { Collapsible, CollapsiblePanel, CollapsibleTrigger } from '@langgenius/dify-ui/collapsible'
@@ -237,7 +237,7 @@ const FeaturedTriggers = ({
type FeaturedTriggerUninstalledItemProps = {
plugin: Plugin
- language: Locale
+ language: PluginLanguage
previewCardHandle: PreviewCardHandle<FeaturedTriggerPreviewPayload>
onInstallSuccess?: () => Promise<void> | void
t: TFunction
diff --git a/web/app/components/workflow/block-selector/rag-tool-recommendations/__tests__/list.spec.tsx b/web/app/components/workflow/block-selector/rag-tool-recommendations/__tests__/list.spec.tsx
index 372d5c895af..4a353b67fc1 100644
--- a/web/app/components/workflow/block-selector/rag-tool-recommendations/__tests__/list.spec.tsx
+++ b/web/app/components/workflow/block-selector/rag-tool-recommendations/__tests__/list.spec.tsx
@@ -12,6 +12,10 @@ import UninstalledItem from '../uninstalled-item'
vi.mock('@/context/i18n', () => ({
useGetLanguage: vi.fn(),
+}))
+
+vi.mock('#i18n', async (importOriginal) => ({
+ ...(await importOriginal<typeof import('#i18n')>()),
useLocale: () => 'en_US',
}))
diff --git a/web/app/components/workflow/block-selector/rag-tool-recommendations/uninstalled-item.tsx b/web/app/components/workflow/block-selector/rag-tool-recommendations/uninstalled-item.tsx
index 53f036c0fc1..d36763aafbc 100644
--- a/web/app/components/workflow/block-selector/rag-tool-recommendations/uninstalled-item.tsx
+++ b/web/app/components/workflow/block-selector/rag-tool-recommendations/uninstalled-item.tsx
@@ -4,10 +4,10 @@ import { Button } from '@langgenius/dify-ui/button'
import { useBoolean } from 'ahooks'
import * as React from 'react'
import { useTranslation } from 'react-i18next'
+import { useLocale } from '#i18n'
import { PluginInstallPermissionProvider } from '@/app/components/plugins/install-plugin/components/plugin-install-permission-provider'
import useWorkspacePluginInstallPermission from '@/app/components/plugins/install-plugin/hooks/use-workspace-plugin-install-permission'
import InstallFromMarketplace from '@/app/components/plugins/install-plugin/install-from-marketplace'
-import { useLocale } from '@/context/i18n'
import BlockIcon from '../../block-icon'
import { BlockEnum } from '../../types'
diff --git a/web/app/components/workflow/nodes/_base/components/form-input-item.helpers.ts b/web/app/components/workflow/nodes/_base/components/form-input-item.helpers.ts
index 3d1f0955d0e..5d6c63bdf65 100644
--- a/web/app/components/workflow/nodes/_base/components/form-input-item.helpers.ts
+++ b/web/app/components/workflow/nodes/_base/components/form-input-item.helpers.ts
@@ -27,7 +27,7 @@ type ShowOnCondition = {
variable: string
}
-type OptionLabel = string | TypeWithI18N
+type OptionLabel = string | Record<string, string>
type SelectableOption = {
icon?: string
diff --git a/web/app/components/workflow/nodes/agent/default.ts b/web/app/components/workflow/nodes/agent/default.ts
index 2ae8493d2b3..6920678ef33 100644
--- a/web/app/components/workflow/nodes/agent/default.ts
+++ b/web/app/components/workflow/nodes/agent/default.ts
@@ -3,7 +3,7 @@ import type { NodeDefault } from '../../types'
import type { AgentNodeType } from './types'
import type { StrategyDetail, StrategyPluginDetail } from '@/app/components/plugins/types'
import { FormTypeEnum } from '@/app/components/header/account-setting/model-provider-page/declarations'
-import { renderI18nObject } from '@/i18n-config'
+import { renderI18nObject } from '@/i18n-config/metadata'
import { BlockEnum } from '../../types'
import { genNodeMetaData } from '../../utils'
diff --git a/web/app/components/workflow/nodes/document-extractor/__tests__/integration.spec.tsx b/web/app/components/workflow/nodes/document-extractor/__tests__/integration.spec.tsx
index d9563c33610..b3b6470ce7d 100644
--- a/web/app/components/workflow/nodes/document-extractor/__tests__/integration.spec.tsx
+++ b/web/app/components/workflow/nodes/document-extractor/__tests__/integration.spec.tsx
@@ -81,7 +81,8 @@ vi.mock('@/service/use-common', () => ({
}),
}))
-vi.mock('@/context/i18n', () => ({
+vi.mock('#i18n', async (importOriginal) => ({
+ ...(await importOriginal<typeof import('#i18n')>()),
useLocale: () => mockLocale,
}))
diff --git a/web/app/components/workflow/nodes/document-extractor/__tests__/panel.spec.tsx b/web/app/components/workflow/nodes/document-extractor/__tests__/panel.spec.tsx
index 8048cae2851..3302087d4b5 100644
--- a/web/app/components/workflow/nodes/document-extractor/__tests__/panel.spec.tsx
+++ b/web/app/components/workflow/nodes/document-extractor/__tests__/panel.spec.tsx
@@ -52,7 +52,8 @@ vi.mock('@/service/use-common', () => ({
}),
}))
-vi.mock('@/context/i18n', () => ({
+vi.mock('#i18n', async (importOriginal) => ({
+ ...(await importOriginal<typeof import('#i18n')>()),
useLocale: () => mockLocale,
}))
diff --git a/web/app/components/workflow/nodes/document-extractor/panel.tsx b/web/app/components/workflow/nodes/document-extractor/panel.tsx
index e4d2bd3bd62..ab684415e1f 100644
--- a/web/app/components/workflow/nodes/document-extractor/panel.tsx
+++ b/web/app/components/workflow/nodes/document-extractor/panel.tsx
@@ -3,9 +3,9 @@ import type { DocExtractorNodeType } from './types'
import type { NodePanelProps } from '@/app/components/workflow/types'
import * as React from 'react'
import { useTranslation } from 'react-i18next'
+import { useLocale } from '#i18n'
import Field from '@/app/components/workflow/nodes/_base/components/field'
import { BlockEnum } from '@/app/components/workflow/types'
-import { useLocale } from '@/context/i18n'
import { LanguagesSupported } from '@/i18n-config/language'
import { useFileSupportTypes } from '@/service/use-common'
import OutputVars, { VarItem } from '../_base/components/output-vars'
diff --git a/web/app/components/workflow/nodes/knowledge-base/node.tsx b/web/app/components/workflow/nodes/knowledge-base/node.tsx
index c4fc6dc901c..504b13e4c9c 100644
--- a/web/app/components/workflow/nodes/knowledge-base/node.tsx
+++ b/web/app/components/workflow/nodes/knowledge-base/node.tsx
@@ -9,7 +9,7 @@ import { ModelTypeEnum } from '@/app/components/header/account-setting/model-pro
import { DERIVED_MODEL_STATUS_BADGE_I18N } from '@/app/components/header/account-setting/model-provider-page/derive-model-status'
import { useLanguage } from '@/app/components/header/account-setting/model-provider-page/hooks'
import { normalizeModelProviderModelsResponse } from '@/app/components/header/account-setting/model-provider-page/utils'
-import { renderI18nObject } from '@/i18n-config'
+import { renderI18nObject } from '@/i18n-config/metadata'
import { consoleQuery } from '@/service/console'
import { useEmbeddingModelStatus } from './hooks/use-embedding-model-status'
import { useSettingsDisplay } from './hooks/use-settings-display'
diff --git a/web/app/components/workflow/nodes/tool/components/tool-date-picker.tsx b/web/app/components/workflow/nodes/tool/components/tool-date-picker.tsx
index f895dc6b905..9f8afb2106a 100644
--- a/web/app/components/workflow/nodes/tool/components/tool-date-picker.tsx
+++ b/web/app/components/workflow/nodes/tool/components/tool-date-picker.tsx
@@ -9,9 +9,9 @@ import { cn } from '@langgenius/dify-ui/cn'
import { noop } from 'es-toolkit/function'
import { useCallback } from 'react'
import { useTranslation } from 'react-i18next'
+import { useLocale } from '#i18n'
import DatePicker from '@/app/components/base/date-and-time-picker/date-picker'
import { toDayjs } from '@/app/components/base/date-and-time-picker/utils/dayjs'
-import { useLocale } from '@/context/i18n'
import { formatToLocalTime } from '@/utils/format'
const DATE_FMT = 'YYYY-MM-DD'
diff --git a/web/app/device/_header.tsx b/web/app/device/_header.tsx
index fe555ad4314..2796f3f005f 100644
--- a/web/app/device/_header.tsx
+++ b/web/app/device/_header.tsx
@@ -1,11 +1,11 @@
'use client'
import { useSuspenseQuery } from '@tanstack/react-query'
+import { useLocale } from '#i18n'
import Divider from '@/app/components/base/divider'
import { DifyLogo } from '@/app/components/base/logo/dify-logo'
import LocaleMenu from '@/app/signin/_locale-menu'
-import { useLocale } from '@/context/i18n'
import { systemFeaturesQueryOptions } from '@/features/system-features/client'
-import { setLocaleOnClient } from '@/i18n-config'
+import { setLocaleOnClient } from '@/i18n-config/client'
import { languages } from '@/i18n-config/language'
import dynamic from '@/next/dynamic'
diff --git a/web/app/reset-password/__tests__/page.spec.tsx b/web/app/reset-password/__tests__/page.spec.tsx
index 96664b20093..a1aa6d94924 100644
--- a/web/app/reset-password/__tests__/page.spec.tsx
+++ b/web/app/reset-password/__tests__/page.spec.tsx
@@ -1,6 +1,6 @@
import { render, screen, waitFor } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
-import { useLocale } from '@/context/i18n'
+import { useLocale } from '#i18n'
import { useRouter, useSearchParams } from '@/next/navigation'
import { sendResetPasswordCode } from '@/service/common'
import ResetPasswordPage from '../page'
@@ -13,7 +13,8 @@ vi.mock('@/app/components/signin/storage', () => ({
useSetCountdownLeftTime: () => mockSetCountdownLeftTime,
}))
-vi.mock('@/context/i18n', () => ({
+vi.mock('#i18n', async (importOriginal) => ({
+ ...(await importOriginal<typeof import('#i18n')>()),
useLocale: vi.fn(),
}))
diff --git a/web/app/reset-password/check-code/__tests__/page.spec.tsx b/web/app/reset-password/check-code/__tests__/page.spec.tsx
index 06eb673a85d..a1dd4bc6297 100644
--- a/web/app/reset-password/check-code/__tests__/page.spec.tsx
+++ b/web/app/reset-password/check-code/__tests__/page.spec.tsx
@@ -1,6 +1,6 @@
import { render, screen, waitFor } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
-import { useLocale } from '@/context/i18n'
+import { useLocale } from '#i18n'
import { useRouter, useSearchParams } from '@/next/navigation'
import { verifyResetPasswordCode } from '@/service/common'
import CheckCodePage from '../page'
@@ -11,7 +11,8 @@ vi.mock('@/app/components/signin/countdown', () => ({
default: () => null,
}))
-vi.mock('@/context/i18n', () => ({
+vi.mock('#i18n', async (importOriginal) => ({
+ ...(await importOriginal<typeof import('#i18n')>()),
useLocale: vi.fn(),
}))
diff --git a/web/app/reset-password/check-code/page.tsx b/web/app/reset-password/check-code/page.tsx
index 5d341f6b1d7..f1d3990e5bc 100644
--- a/web/app/reset-password/check-code/page.tsx
+++ b/web/app/reset-password/check-code/page.tsx
@@ -6,8 +6,8 @@ import { Input } from '@langgenius/dify-ui/input'
import { toast } from '@langgenius/dify-ui/toast'
import { useState } from 'react'
import { useTranslation } from 'react-i18next'
+import { useLocale } from '#i18n'
import Countdown from '@/app/components/signin/countdown'
-import { useLocale } from '@/context/i18n'
import useDocumentTitle from '@/hooks/use-document-title'
import { useRouter, useSearchParams } from '@/next/navigation'
import { sendResetPasswordCode, verifyResetPasswordCode } from '@/service/common'
diff --git a/web/app/reset-password/page.tsx b/web/app/reset-password/page.tsx
index e3fc1ed7301..1d3fd131c6b 100644
--- a/web/app/reset-password/page.tsx
+++ b/web/app/reset-password/page.tsx
@@ -6,8 +6,8 @@ import { Input } from '@langgenius/dify-ui/input'
import { toast } from '@langgenius/dify-ui/toast'
import { useState } from 'react'
import { useTranslation } from 'react-i18next'
+import { useLocale } from '#i18n'
import { emailRegex } from '@/config'
-import { useLocale } from '@/context/i18n'
import useDocumentTitle from '@/hooks/use-document-title'
import Link from '@/next/link'
import { useRouter, useSearchParams } from '@/next/navigation'
diff --git a/web/app/signin/__tests__/_header.spec.tsx b/web/app/signin/__tests__/_header.spec.tsx
index e67bd976445..86778357cd3 100644
--- a/web/app/signin/__tests__/_header.spec.tsx
+++ b/web/app/signin/__tests__/_header.spec.tsx
@@ -1,9 +1,9 @@
import { fireEvent, screen } from '@testing-library/react'
-import { setLocaleOnClient } from '@/i18n-config'
+import { setLocaleOnClient } from '@/i18n-config/client'
import { renderWithConsoleQuery as render } from '@/test/console/query-data'
import Header from '../_header'
-vi.mock('@/i18n-config', () => ({
+vi.mock('@/i18n-config/client', () => ({
setLocaleOnClient: vi.fn(),
}))
diff --git a/web/app/signin/_header.tsx b/web/app/signin/_header.tsx
index 93bbd93ceb6..9e309c5c902 100644
--- a/web/app/signin/_header.tsx
+++ b/web/app/signin/_header.tsx
@@ -1,10 +1,10 @@
'use client'
import { useSuspenseQuery } from '@tanstack/react-query'
+import { useLocale } from '#i18n'
import Divider from '@/app/components/base/divider'
import { DifyLogo } from '@/app/components/base/logo/dify-logo'
-import { useLocale } from '@/context/i18n'
import { systemFeaturesQueryOptions } from '@/features/system-features/client'
-import { setLocaleOnClient } from '@/i18n-config'
+import { setLocaleOnClient } from '@/i18n-config/client'
import { languages } from '@/i18n-config/language'
import dynamic from '@/next/dynamic'
import LocaleMenu from './_locale-menu'
diff --git a/web/app/signin/check-code/page.tsx b/web/app/signin/check-code/page.tsx
index cabd983e8b6..c38b0045529 100644
--- a/web/app/signin/check-code/page.tsx
+++ b/web/app/signin/check-code/page.tsx
@@ -7,11 +7,11 @@ import { toast } from '@langgenius/dify-ui/toast'
import { useQueryClient, useSuspenseQuery } from '@tanstack/react-query'
import { useEffect, useRef, useState } from 'react'
import { useTranslation } from 'react-i18next'
+import { useLocale } from '#i18n'
import { trackEvent } from '@/app/components/base/amplitude'
import Countdown from '@/app/components/signin/countdown'
import { COUNT_DOWN_TIME_MS, useSetCountdownLeftTime } from '@/app/components/signin/storage'
import { TURNSTILE_SITE_KEY } from '@/config'
-import { useLocale } from '@/context/i18n'
import { userProfileQueryOptions } from '@/features/account-profile/client'
import { systemFeaturesQueryOptions } from '@/features/system-features/client'
import useDocumentTitle from '@/hooks/use-document-title'
diff --git a/web/app/signin/components/__tests__/mail-and-code-auth.spec.tsx b/web/app/signin/components/__tests__/mail-and-code-auth.spec.tsx
index acd71774a45..8eeacb304b0 100644
--- a/web/app/signin/components/__tests__/mail-and-code-auth.spec.tsx
+++ b/web/app/signin/components/__tests__/mail-and-code-auth.spec.tsx
@@ -49,7 +49,8 @@ vi.mock('@/next/navigation', () => ({
useSearchParams: () => new URLSearchParams(),
}))
-vi.mock('@/context/i18n', () => ({
+vi.mock('#i18n', async (importOriginal) => ({
+ ...(await importOriginal<typeof import('#i18n')>()),
useLocale: () => 'en-US',
}))
diff --git a/web/app/signin/components/__tests__/social-auth.spec.tsx b/web/app/signin/components/__tests__/social-auth.spec.tsx
index 6500df97925..a65ee2b7e64 100644
--- a/web/app/signin/components/__tests__/social-auth.spec.tsx
+++ b/web/app/signin/components/__tests__/social-auth.spec.tsx
@@ -1,6 +1,6 @@
import { render, screen } from '@testing-library/react'
import { beforeEach, describe, expect, it, vi } from 'vite-plus/test'
-import { useLocale } from '@/context/i18n'
+import { useLocale } from '#i18n'
import { useSearchParams } from '@/next/navigation'
import { getBrowserTimezone } from '@/utils/timezone'
import SocialAuth from '../social-auth'
@@ -9,7 +9,8 @@ vi.mock('@/next/navigation', () => ({
useSearchParams: vi.fn(),
}))
-vi.mock('@/context/i18n', () => ({
+vi.mock('#i18n', async (importOriginal) => ({
+ ...(await importOriginal<typeof import('#i18n')>()),
useLocale: vi.fn(),
}))
diff --git a/web/app/signin/components/mail-and-code-auth.tsx b/web/app/signin/components/mail-and-code-auth.tsx
index 9cc9f41b3ab..c56740a9516 100644
--- a/web/app/signin/components/mail-and-code-auth.tsx
+++ b/web/app/signin/components/mail-and-code-auth.tsx
@@ -5,9 +5,9 @@ import { Input } from '@langgenius/dify-ui/input'
import { useSuspenseQuery } from '@tanstack/react-query'
import { useState } from 'react'
import { useTranslation } from 'react-i18next'
+import { useLocale } from '#i18n'
import { COUNT_DOWN_TIME_MS, useSetCountdownLeftTime } from '@/app/components/signin/storage'
import { emailRegex, TURNSTILE_SITE_KEY } from '@/config'
-import { useLocale } from '@/context/i18n'
import { systemFeaturesQueryOptions } from '@/features/system-features/client'
import { useRouter, useSearchParams } from '@/next/navigation'
import { sendEMailLoginCode } from '@/service/common'
diff --git a/web/app/signin/components/social-auth.tsx b/web/app/signin/components/social-auth.tsx
index 6c152856513..328f9c36933 100644
--- a/web/app/signin/components/social-auth.tsx
+++ b/web/app/signin/components/social-auth.tsx
@@ -1,8 +1,8 @@
import { buttonVariants } from '@langgenius/dify-ui/button'
import { cn } from '@langgenius/dify-ui/cn'
import { useTranslation } from 'react-i18next'
+import { useLocale } from '#i18n'
import { API_PREFIX } from '@/config'
-import { useLocale } from '@/context/i18n'
import { useSearchParams } from '@/next/navigation'
import { getPurifyHref } from '@/utils'
import { getBrowserTimezone } from '@/utils/timezone'
diff --git a/web/app/signin/invite-settings/__tests__/page.spec.tsx b/web/app/signin/invite-settings/__tests__/page.spec.tsx
index 712a6f7bf55..52ff5a09e10 100644
--- a/web/app/signin/invite-settings/__tests__/page.spec.tsx
+++ b/web/app/signin/invite-settings/__tests__/page.spec.tsx
@@ -3,7 +3,7 @@ import { useQuery } from '@tanstack/react-query'
import { render, screen, waitFor } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import { beforeEach, describe, expect, it, vi } from 'vite-plus/test'
-import { useLocale } from '@/context/i18n'
+import { useLocale } from '#i18n'
import { useRouter, useSearchParams } from '@/next/navigation'
import { activateMember } from '@/service/common'
import { useInvitationCheck } from '@/service/use-common'
@@ -42,7 +42,8 @@ vi.mock('@tanstack/react-query', async () => {
}
})
-vi.mock('@/context/i18n', () => ({
+vi.mock('#i18n', async (importOriginal) => ({
+ ...(await importOriginal<typeof import('#i18n')>()),
useLocale: vi.fn(),
}))
@@ -50,6 +51,9 @@ vi.mock('@/i18n-config', () => ({
i18n: {
defaultLocale: 'en-US',
},
+}))
+
+vi.mock('@/i18n-config/client', () => ({
setLocaleOnClient: vi.fn(() => Promise.resolve()),
}))
diff --git a/web/app/signin/invite-settings/page.tsx b/web/app/signin/invite-settings/page.tsx
index 744f649422b..19b11b0198a 100644
--- a/web/app/signin/invite-settings/page.tsx
+++ b/web/app/signin/invite-settings/page.tsx
@@ -17,13 +17,14 @@ import {
import { useQuery, useQueryClient, useSuspenseQuery } from '@tanstack/react-query'
import { useCallback, useEffect, useState } from 'react'
import { useTranslation } from 'react-i18next'
+import { useLocale } from '#i18n'
import Loading from '@/app/components/base/loading'
import { LICENSE_LINK } from '@/constants/link'
-import { useLocale } from '@/context/i18n'
import { isLegacyBase401, userProfileQueryOptions } from '@/features/account-profile/client'
import { systemFeaturesQueryOptions } from '@/features/system-features/client'
import useDocumentTitle from '@/hooks/use-document-title'
-import { i18n, setLocaleOnClient } from '@/i18n-config'
+import { i18n } from '@/i18n-config'
+import { setLocaleOnClient } from '@/i18n-config/client'
import { languages } from '@/i18n-config/language'
import Link from '@/next/link'
import { useRouter, useSearchParams } from '@/next/navigation'
diff --git a/web/app/signup/check-code/__tests__/page.spec.tsx b/web/app/signup/check-code/__tests__/page.spec.tsx
index 43e91c033ad..a9220931184 100644
--- a/web/app/signup/check-code/__tests__/page.spec.tsx
+++ b/web/app/signup/check-code/__tests__/page.spec.tsx
@@ -1,7 +1,7 @@
import type { MockedFunction } from 'vite-plus/test'
import { render, screen, waitFor } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
-import { useLocale } from '@/context/i18n'
+import { useLocale } from '#i18n'
import { useRouter, useSearchParams } from '@/next/navigation'
import { useMailValidity, useSendMail } from '@/service/use-common'
import CheckCode from '../page'
@@ -20,7 +20,8 @@ vi.mock('@/app/components/signin/countdown', () => ({
),
}))
-vi.mock('@/context/i18n', () => ({
+vi.mock('#i18n', async (importOriginal) => ({
+ ...(await importOriginal<typeof import('#i18n')>()),
useLocale: vi.fn(),
}))
diff --git a/web/app/signup/check-code/page.tsx b/web/app/signup/check-code/page.tsx
index cafddd4495b..97297f5a89a 100644
--- a/web/app/signup/check-code/page.tsx
+++ b/web/app/signup/check-code/page.tsx
@@ -7,8 +7,8 @@ import { Input } from '@langgenius/dify-ui/input'
import { toast } from '@langgenius/dify-ui/toast'
import { useState } from 'react'
import { useTranslation } from 'react-i18next'
+import { useLocale } from '#i18n'
import Countdown from '@/app/components/signin/countdown'
-import { useLocale } from '@/context/i18n'
import useDocumentTitle from '@/hooks/use-document-title'
import { useRouter, useSearchParams } from '@/next/navigation'
import { useMailValidity, useSendMail } from '@/service/use-common'
diff --git a/web/app/signup/components/input-mail.spec.tsx b/web/app/signup/components/input-mail.spec.tsx
index 42b6f6a2830..dbfebc1934c 100644
--- a/web/app/signup/components/input-mail.spec.tsx
+++ b/web/app/signup/components/input-mail.spec.tsx
@@ -2,7 +2,7 @@ import type { MockedFunction } from 'vite-plus/test'
import { screen, waitFor } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import * as React from 'react'
-import { useLocale } from '@/context/i18n'
+import { useLocale } from '#i18n'
import { useSearchParams } from '@/next/navigation'
import { useSendMail } from '@/service/use-common'
import { renderWithConsoleQuery } from '@/test/console/query-data'
@@ -31,7 +31,8 @@ vi.mock('@/next/link', () => ({
),
}))
-vi.mock('@/context/i18n', () => ({
+vi.mock('#i18n', async (importOriginal) => ({
+ ...(await importOriginal<typeof import('#i18n')>()),
useLocale: vi.fn(),
}))
diff --git a/web/app/signup/components/input-mail.tsx b/web/app/signup/components/input-mail.tsx
index eb817a8c0f9..fd68fafff53 100644
--- a/web/app/signup/components/input-mail.tsx
+++ b/web/app/signup/components/input-mail.tsx
@@ -6,9 +6,9 @@ import { Form } from '@langgenius/dify-ui/form'
import { Input } from '@langgenius/dify-ui/input'
import { useSuspenseQuery } from '@tanstack/react-query'
import { useTranslation } from 'react-i18next'
+import { useLocale } from '#i18n'
import Split from '@/app/signin/split'
import { emailRegex } from '@/config'
-import { useLocale } from '@/context/i18n'
import { systemFeaturesQueryOptions } from '@/features/system-features/client'
import Link from '@/next/link'
import { useSearchParams } from '@/next/navigation'
diff --git a/web/app/signup/set-password/__tests__/page.spec.tsx b/web/app/signup/set-password/__tests__/page.spec.tsx
index 1fdfab5daf8..17f2ac59834 100644
--- a/web/app/signup/set-password/__tests__/page.spec.tsx
+++ b/web/app/signup/set-password/__tests__/page.spec.tsx
@@ -5,7 +5,7 @@ import { render, screen, waitFor } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import Cookies from 'js-cookie'
import { beforeEach, describe, expect, it, vi } from 'vite-plus/test'
-import { useLocale } from '@/context/i18n'
+import { useLocale } from '#i18n'
import { useRouter, useSearchParams } from '@/next/navigation'
import { useMailRegister } from '@/service/use-common'
import { seedSystemFeatures } from '@/test/console/query-data'
@@ -22,7 +22,8 @@ const {
mockSendGAEvent: vi.fn(),
}))
-vi.mock('@/context/i18n', () => ({
+vi.mock('#i18n', async (importOriginal) => ({
+ ...(await importOriginal<typeof import('#i18n')>()),
useLocale: vi.fn(),
}))
diff --git a/web/app/signup/set-password/page.tsx b/web/app/signup/set-password/page.tsx
index bf6f2ac347f..81b2148df88 100644
--- a/web/app/signup/set-password/page.tsx
+++ b/web/app/signup/set-password/page.tsx
@@ -17,10 +17,10 @@ import { useQueryClient } from '@tanstack/react-query'
import Cookies from 'js-cookie'
import { useCallback, useRef } from 'react'
import { useTranslation } from 'react-i18next'
+import { useLocale } from '#i18n'
import { rememberRegistrationSuccess } from '@/app/components/base/amplitude/registration-tracking'
import { resolvePostLoginRedirect } from '@/app/signin/utils/post-login-redirect'
import { validPassword } from '@/config'
-import { useLocale } from '@/context/i18n'
import useDocumentTitle from '@/hooks/use-document-title'
import { useRouter, useSearchParams } from '@/next/navigation'
import { consoleQuery } from '@/service/console'
diff --git a/web/context/i18n.spec.ts b/web/context/i18n.spec.ts
index f5b52907e89..ed8b1b1351d 100644
--- a/web/context/i18n.spec.ts
+++ b/web/context/i18n.spec.ts
@@ -1,7 +1,7 @@
import type { DocPathMap } from './i18n'
import type { DocPathWithoutLang } from '@/types/doc-paths'
import { renderHook } from '@testing-library/react'
-import { useTranslation } from '#i18n'
+import { useLocale } from '#i18n'
import { getDocLanguage } from '@/i18n-config/language'
import { defaultDocBaseUrl, enterpriseDocBaseUrl, useDocLink } from './i18n'
@@ -11,9 +11,7 @@ const mockDeploymentEdition = vi.hoisted(() => ({
// Mock dependencies
vi.mock('#i18n', () => ({
- useTranslation: vi.fn(() => ({
- i18n: { language: 'en-US' },
- })),
+ useLocale: vi.fn(() => 'en-US'),
}))
vi.mock('jotai', async (importOriginal) => ({
@@ -30,16 +28,18 @@ vi.mock('@/i18n-config/language', () => ({
}
return map[locale] || 'en'
}),
- getLanguage: vi.fn(),
+}))
+
+vi.mock('@/i18n-config/metadata', async (importOriginal) => ({
+ ...(await importOriginal<typeof import('@/i18n-config/metadata')>()),
+ getPluginLanguage: vi.fn(),
}))
describe('useDocLink', () => {
beforeEach(() => {
vi.clearAllMocks()
mockDeploymentEdition.value = 'CLOUD'
- vi.mocked(useTranslation).mockReturnValue({
- i18n: { language: 'en-US' },
- } as ReturnType<typeof useTranslation>)
+ vi.mocked(useLocale).mockReturnValue('en-US')
vi.mocked(getDocLanguage).mockReturnValue('en')
})
@@ -108,9 +108,7 @@ describe('useDocLink', () => {
describe('PathMap handling', () => {
it('should use path from pathMap when locale matches', () => {
- vi.mocked(useTranslation).mockReturnValue({
- i18n: { language: 'zh-Hans' },
- } as ReturnType<typeof useTranslation>)
+ vi.mocked(useLocale).mockReturnValue('zh-Hans')
vi.mocked(getDocLanguage).mockReturnValue('zh')
const pathMap: DocPathMap = {
@@ -124,9 +122,7 @@ describe('useDocLink', () => {
})
it('should use default path when locale not in pathMap', () => {
- vi.mocked(useTranslation).mockReturnValue({
- i18n: { language: 'ja-JP' },
- } as ReturnType<typeof useTranslation>)
+ vi.mocked(useLocale).mockReturnValue('ja-JP')
vi.mocked(getDocLanguage).mockReturnValue('ja')
const pathMap: DocPathMap = {
@@ -311,9 +307,7 @@ describe('useDocLink', () => {
})
it('should use Chinese and Japanese enterprise documentation languages', () => {
- vi.mocked(useTranslation).mockReturnValue({
- i18n: { language: 'zh-Hans' },
- } as ReturnType<typeof useTranslation>)
+ vi.mocked(useLocale).mockReturnValue('zh-Hans')
vi.mocked(getDocLanguage).mockReturnValue('zh')
const { result, rerender } = renderHook(() => useDocLink())
@@ -321,9 +315,7 @@ describe('useDocLink', () => {
`${enterpriseDocBaseUrl}/zh/use/nodes/start`,
)
- vi.mocked(useTranslation).mockReturnValue({
- i18n: { language: 'ja-JP' },
- } as ReturnType<typeof useTranslation>)
+ vi.mocked(useLocale).mockReturnValue('ja-JP')
vi.mocked(getDocLanguage).mockReturnValue('ja')
rerender()
@@ -335,9 +327,7 @@ describe('useDocLink', () => {
describe('Language prefix handling', () => {
it('should add /en prefix for English locale', () => {
- vi.mocked(useTranslation).mockReturnValue({
- i18n: { language: 'en-US' },
- } as ReturnType<typeof useTranslation>)
+ vi.mocked(useLocale).mockReturnValue('en-US')
vi.mocked(getDocLanguage).mockReturnValue('en')
const { result } = renderHook(() => useDocLink())
@@ -346,9 +336,7 @@ describe('useDocLink', () => {
})
it('should add /zh prefix for Chinese locale', () => {
- vi.mocked(useTranslation).mockReturnValue({
- i18n: { language: 'zh-Hans' },
- } as ReturnType<typeof useTranslation>)
+ vi.mocked(useLocale).mockReturnValue('zh-Hans')
vi.mocked(getDocLanguage).mockReturnValue('zh')
const { result } = renderHook(() => useDocLink())
@@ -357,9 +345,7 @@ describe('useDocLink', () => {
})
it('should add /ja prefix for Japanese locale', () => {
- vi.mocked(useTranslation).mockReturnValue({
- i18n: { language: 'ja-JP' },
- } as ReturnType<typeof useTranslation>)
+ vi.mocked(useLocale).mockReturnValue('ja-JP')
vi.mocked(getDocLanguage).mockReturnValue('ja')
const { result } = renderHook(() => useDocLink())
@@ -370,9 +356,7 @@ describe('useDocLink', () => {
describe('API reference path handling', () => {
it('should add language prefix for Chinese API reference paths', () => {
- vi.mocked(useTranslation).mockReturnValue({
- i18n: { language: 'zh-Hans' },
- } as ReturnType<typeof useTranslation>)
+ vi.mocked(useLocale).mockReturnValue('zh-Hans')
vi.mocked(getDocLanguage).mockReturnValue('zh')
const { result } = renderHook(() => useDocLink())
@@ -381,9 +365,7 @@ describe('useDocLink', () => {
})
it('should add language prefix for Japanese API reference paths', () => {
- vi.mocked(useTranslation).mockReturnValue({
- i18n: { language: 'ja-JP' },
- } as ReturnType<typeof useTranslation>)
+ vi.mocked(useLocale).mockReturnValue('ja-JP')
vi.mocked(getDocLanguage).mockReturnValue('ja')
const { result } = renderHook(() => useDocLink())
@@ -392,9 +374,7 @@ describe('useDocLink', () => {
})
it('should not translate API reference path for English locale', () => {
- vi.mocked(useTranslation).mockReturnValue({
- i18n: { language: 'en-US' },
- } as ReturnType<typeof useTranslation>)
+ vi.mocked(useLocale).mockReturnValue('en-US')
vi.mocked(getDocLanguage).mockReturnValue('en')
const { result } = renderHook(() => useDocLink())
@@ -403,9 +383,7 @@ describe('useDocLink', () => {
})
it('should keep the API reference slug unchanged for non-English locale', () => {
- vi.mocked(useTranslation).mockReturnValue({
- i18n: { language: 'zh-Hans' },
- } as ReturnType<typeof useTranslation>)
+ vi.mocked(useLocale).mockReturnValue('zh-Hans')
vi.mocked(getDocLanguage).mockReturnValue('zh')
const { result } = renderHook(() => useDocLink())
@@ -414,9 +392,7 @@ describe('useDocLink', () => {
})
it('should keep language prefix for API reference paths', () => {
- vi.mocked(useTranslation).mockReturnValue({
- i18n: { language: 'zh-Hans' },
- } as ReturnType<typeof useTranslation>)
+ vi.mocked(useLocale).mockReturnValue('zh-Hans')
vi.mocked(getDocLanguage).mockReturnValue('zh')
const { result } = renderHook(() => useDocLink())
@@ -425,9 +401,7 @@ describe('useDocLink', () => {
})
it('should use the current knowledge API guide path directly', () => {
- vi.mocked(useTranslation).mockReturnValue({
- i18n: { language: 'zh-Hans' },
- } as ReturnType<typeof useTranslation>)
+ vi.mocked(useLocale).mockReturnValue('zh-Hans')
vi.mocked(getDocLanguage).mockReturnValue('zh')
const { result } = renderHook(() => useDocLink())
@@ -436,9 +410,7 @@ describe('useDocLink', () => {
})
it('should not translate non-API-reference paths', () => {
- vi.mocked(useTranslation).mockReturnValue({
- i18n: { language: 'zh-Hans' },
- } as ReturnType<typeof useTranslation>)
+ vi.mocked(useLocale).mockReturnValue('zh-Hans')
vi.mocked(getDocLanguage).mockReturnValue('zh')
const { result } = renderHook(() => useDocLink())
diff --git a/web/context/i18n.ts b/web/context/i18n.ts
index e2fe22c67c1..376731b8558 100644
--- a/web/context/i18n.ts
+++ b/web/context/i18n.ts
@@ -1,22 +1,18 @@
import type { DeploymentEdition } from '@dify/contracts/api/console/system-features/types.gen'
-import type { Locale } from '@/i18n-config/language'
+import type { Locale } from '@/i18n-config/locale'
import type { DocLanguage, DocPathWithoutLang, DocsProduct } from '@/types/doc-paths'
import { useAtomValue } from 'jotai'
import { useCallback } from 'react'
-import { useTranslation } from '#i18n'
+import { useLocale } from '#i18n'
import { deploymentEditionAtom } from '@/features/system-features/state'
-import { getDocLanguage, getLanguage } from '@/i18n-config/language'
+import { getDocLanguage } from '@/i18n-config/language'
+import { getPluginLanguage } from '@/i18n-config/metadata'
import { docPathProductAvailability, isProductlessDocPath } from '@/types/doc-paths'
-export const useLocale = () => {
- const { i18n } = useTranslation()
- return i18n.language as Locale
-}
-
export const useGetLanguage = () => {
const locale = useLocale()
- return getLanguage(locale)
+ return getPluginLanguage(locale)
}
export const defaultDocBaseUrl = 'https://docs.dify.ai'
diff --git a/web/features/agent-v2/agent-detail/access-config/page.tsx b/web/features/agent-v2/agent-detail/access-config/page.tsx
index 1b5449bd3d6..89864e98863 100644
--- a/web/features/agent-v2/agent-detail/access-config/page.tsx
+++ b/web/features/agent-v2/agent-detail/access-config/page.tsx
@@ -5,8 +5,8 @@ import { Button } from '@langgenius/dify-ui/button'
import { keepPreviousData, useMutation, useQuery } from '@tanstack/react-query'
import { useState } from 'react'
import { useTranslation } from 'react-i18next'
+import { useLocale } from '#i18n'
import AccessRulesEditor from '@/app/components/access-rules-editor'
-import { useLocale } from '@/context/i18n'
import { useAgentPermissions } from '@/features/agent-v2/permissions'
import { getAccessControlTemplateLanguage } from '@/i18n-config/language'
import { RESOURCE_ACCESS_SETTINGS_PAGE_SIZE } from '@/service/access-control/constants'
diff --git a/web/features/agent-v2/agent-detail/configure/components/orchestrate/advanced/content-moderation.tsx b/web/features/agent-v2/agent-detail/configure/components/orchestrate/advanced/content-moderation.tsx
index bd53a1f7ad7..33dd0a3e642 100644
--- a/web/features/agent-v2/agent-detail/configure/components/orchestrate/advanced/content-moderation.tsx
+++ b/web/features/agent-v2/agent-detail/configure/components/orchestrate/advanced/content-moderation.tsx
@@ -7,9 +7,9 @@ import { Button } from '@langgenius/dify-ui/button'
import { Switch } from '@langgenius/dify-ui/switch'
import { useCallback, useMemo } from 'react'
import { useTranslation } from 'react-i18next'
+import { useLocale } from '#i18n'
import { FeaturesProvider } from '@/app/components/base/features'
import { useFeatures, useFeaturesStore } from '@/app/components/base/features/hooks'
-import { useLocale } from '@/context/i18n'
import { useModalContext } from '@/context/modal-context'
import {
useAppFeatures,
diff --git a/web/features/agent-v2/agent-detail/monitoring/__tests__/page.spec.tsx b/web/features/agent-v2/agent-detail/monitoring/__tests__/page.spec.tsx
index b526705f68d..85c2cfa260b 100644
--- a/web/features/agent-v2/agent-detail/monitoring/__tests__/page.spec.tsx
+++ b/web/features/agent-v2/agent-detail/monitoring/__tests__/page.spec.tsx
@@ -39,7 +39,8 @@ vi.mock('echarts-for-react', () => ({
},
}))
-vi.mock('@/context/i18n', () => ({
+vi.mock('#i18n', async (importOriginal) => ({
+ ...(await importOriginal<typeof import('#i18n')>()),
useLocale: () => 'en-US',
}))
diff --git a/web/features/agent-v2/agent-detail/monitoring/time-range-picker.tsx b/web/features/agent-v2/agent-detail/monitoring/time-range-picker.tsx
index 3c6bf916a5c..1e0e86df5a8 100644
--- a/web/features/agent-v2/agent-detail/monitoring/time-range-picker.tsx
+++ b/web/features/agent-v2/agent-detail/monitoring/time-range-picker.tsx
@@ -16,8 +16,8 @@ import dayjs from 'dayjs'
import { noop } from 'es-toolkit/function'
import { useState } from 'react'
import { useTranslation } from 'react-i18next'
+import { useLocale } from '#i18n'
import DatePicker from '@/app/components/base/date-and-time-picker/date-picker'
-import { useLocale } from '@/context/i18n'
import { formatToLocalTime } from '@/utils/format'
export type AgentMonitoringPeriod = {
diff --git a/web/features/home/banner/banner.tsx b/web/features/home/banner/banner.tsx
index 799d2d82bce..57ff8a17a85 100644
--- a/web/features/home/banner/banner.tsx
+++ b/web/features/home/banner/banner.tsx
@@ -8,9 +8,9 @@ import { IconButton } from '@langgenius/dify-ui/icon-button'
import { useSuspenseQuery } from '@tanstack/react-query'
import { useEffect, useId, useRef, useState } from 'react'
import { useTranslation } from 'react-i18next'
+import { useLocale } from '#i18n'
import { trackEvent } from '@/app/components/base/amplitude'
import { Carousel, useCarousel } from '@/app/components/base/carousel'
-import { useLocale } from '@/context/i18n'
import { userProfileQueryOptions } from '@/features/account-profile/client'
import { BannerItem } from './banner-item'
import { IndicatorButton } from './indicator-button'
diff --git a/web/features/home/banner/home-banner.tsx b/web/features/home/banner/home-banner.tsx
index 1e116ba9cd5..e62a42077f9 100644
--- a/web/features/home/banner/home-banner.tsx
+++ b/web/features/home/banner/home-banner.tsx
@@ -1,7 +1,7 @@
'use client'
import { useSuspenseQuery } from '@tanstack/react-query'
-import { useLocale } from '@/context/i18n'
+import { useLocale } from '#i18n'
import { consoleQuery } from '@/service/console'
import { Banner } from './banner'
diff --git a/web/features/home/home-content/home-content.tsx b/web/features/home/home-content/home-content.tsx
index ec216c1227c..5c56ed34de6 100644
--- a/web/features/home/home-content/home-content.tsx
+++ b/web/features/home/home-content/home-content.tsx
@@ -10,6 +10,7 @@ import { useAtomValue, useSetAtom } from 'jotai'
import { useQueryState } from 'nuqs'
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
import { useTranslation } from 'react-i18next'
+import { useLocale } from '#i18n'
import { MAIN_NAV_APP_CARD_GRID_CLASS_NAME } from '@/app/components/main-nav/app-card-grid'
import {
getStepByStepTourPermissionVariant,
@@ -25,7 +26,6 @@ import {
} from '@/app/components/step-by-step-tour/state'
import { STEP_BY_STEP_TOUR_TARGETS } from '@/app/components/step-by-step-tour/target-registry'
import { STEP_BY_STEP_TOUR_TASKS } from '@/app/components/step-by-step-tour/tasks'
-import { useLocale } from '@/context/i18n'
import { workspacePermissionKeysAtom } from '@/context/permission-state'
import { systemFeaturesQueryOptions } from '@/features/system-features/client'
import { useImportDSL } from '@/hooks/use-import-dsl'
diff --git a/web/features/new-rag/__tests__/new-knowledge-list.spec.tsx b/web/features/new-rag/__tests__/new-knowledge-list.spec.tsx
index fbc628bd722..fff892f4d76 100644
--- a/web/features/new-rag/__tests__/new-knowledge-list.spec.tsx
+++ b/web/features/new-rag/__tests__/new-knowledge-list.spec.tsx
@@ -87,6 +87,10 @@ vi.mock('@/context/permission-state', () => ({
vi.mock('@/context/i18n', () => ({
useDocLink: () => (path?: string) => `https://docs.example.com${path ?? ''}`,
+}))
+
+vi.mock('#i18n', async (importOriginal) => ({
+ ...(await importOriginal<typeof import('#i18n')>()),
useLocale: () => 'en-US',
}))
diff --git a/web/hooks/use-format-time-from-now.spec.ts b/web/hooks/use-format-time-from-now.spec.ts
index da89c8206c8..adb0ad9f7e5 100644
--- a/web/hooks/use-format-time-from-now.spec.ts
+++ b/web/hooks/use-format-time-from-now.spec.ts
@@ -14,10 +14,11 @@ import type { Mock } from 'vite-plus/test'
*/
import { renderHook } from '@testing-library/react'
// Import after mock to get the mocked version
-import { useLocale } from '@/context/i18n'
+import { useLocale } from '#i18n'
import { useFormatTimeFromNow } from './use-format-time-from-now'
-vi.mock('@/context/i18n', () => ({
+vi.mock('#i18n', async (importOriginal) => ({
+ ...(await importOriginal<typeof import('#i18n')>()),
useLocale: vi.fn(() => 'en-US'),
}))
diff --git a/web/hooks/use-format-time-from-now.ts b/web/hooks/use-format-time-from-now.ts
index 759d24a9b34..e08418fd32d 100644
--- a/web/hooks/use-format-time-from-now.ts
+++ b/web/hooks/use-format-time-from-now.ts
@@ -1,7 +1,7 @@
import dayjs from 'dayjs'
import relativeTime from 'dayjs/plugin/relativeTime'
import { useCallback } from 'react'
-import { useLocale } from '@/context/i18n'
+import { useLocale } from '#i18n'
import { localeMap } from '@/i18n-config/language'
import 'dayjs/locale/az'
import 'dayjs/locale/de'
diff --git a/web/hooks/use-i18n.ts b/web/hooks/use-i18n.ts
index 606ea9da7f6..85fc7682f83 100644
--- a/web/hooks/use-i18n.ts
+++ b/web/hooks/use-i18n.ts
@@ -1,9 +1,7 @@
-import { useLanguage } from '@/app/components/header/account-setting/model-provider-page/hooks'
-import { renderI18nObject } from '@/i18n-config'
+import { useLocale } from '#i18n'
+import { getModelLanguage, renderI18nObject } from '@/i18n-config/metadata'
export const useRenderI18nObject = () => {
- const language = useLanguage()
- return (obj: Record<string, string>) => {
- return renderI18nObject(obj, language)
- }
+ const language = getModelLanguage(useLocale())
+ return (obj: Record<string, string>) => renderI18nObject(obj, language)
}
diff --git a/web/hooks/use-timestamp.spec.ts b/web/hooks/use-timestamp.spec.ts
index d4b62f7411b..58d41d1bc72 100644
--- a/web/hooks/use-timestamp.spec.ts
+++ b/web/hooks/use-timestamp.spec.ts
@@ -8,7 +8,8 @@ import useTimestamp from './use-timestamp'
const mockUseLocale = vi.hoisted(() => vi.fn(() => 'en-US'))
-vi.mock('@/context/i18n', () => ({
+vi.mock('#i18n', async (importOriginal) => ({
+ ...(await importOriginal<typeof import('#i18n')>()),
useLocale: mockUseLocale,
}))
diff --git a/web/hooks/use-timestamp.ts b/web/hooks/use-timestamp.ts
index 35160d6c97b..b710d62bee8 100644
--- a/web/hooks/use-timestamp.ts
+++ b/web/hooks/use-timestamp.ts
@@ -4,7 +4,7 @@ import dayjs from 'dayjs'
import timezone from 'dayjs/plugin/timezone'
import utc from 'dayjs/plugin/utc'
import { useCallback } from 'react'
-import { useLocale } from '@/context/i18n'
+import { useLocale } from '#i18n'
import { userProfileQueryOptions } from '@/features/account-profile/client'
import { formatToLocalTime } from '@/utils/format'
diff --git a/web/i18n-config/README.md b/web/i18n-config/README.md
index 385a52523a5..640213339d7 100644
--- a/web/i18n-config/README.md
+++ b/web/i18n-config/README.md
@@ -6,7 +6,11 @@ English JSON files under `web/i18n/en-US/` are the source locale. Other locale d
- `languages.ts` is the source of truth for supported Web locales.
- `locale.ts` owns canonical UI locale tags, the default locale, and input normalization.
-- `language.ts` owns product-specific locale mappings.
+- `language.ts` owns documentation, access-template, and date-library locale mappings.
+- `metadata.ts` owns plugin/model language mappings and localized metadata selection.
+- `index.ts` exports only shared configuration and the canonical UI locale type.
+- `client.ts` owns client language changes and cookie persistence.
+- `#i18n` selects the client or server translation hooks; use it for `useLocale`.
- `resources.ts` owns the typed namespace registry. File names use kebab case while namespaces use camel case, for example `app-debug.json` and `appDebug`.
- `locale-resources/<locale>.ts` owns lazy loading for one locale.
- `settings.ts` owns shared i18next options.
diff --git a/web/i18n-config/__tests__/client-locale.spec.ts b/web/i18n-config/__tests__/client-locale.spec.ts
index 1f78d7eabd1..a3d808b8603 100644
--- a/web/i18n-config/__tests__/client-locale.spec.ts
+++ b/web/i18n-config/__tests__/client-locale.spec.ts
@@ -1,6 +1,5 @@
import Cookies from 'js-cookie'
-import { setLocaleOnClient } from '..'
-import { changeLanguage } from '../client'
+import { changeLanguage, setLocaleOnClient } from '../client'
const mocks = vi.hoisted(() => ({ changeLanguage: vi.fn() }))
diff --git a/web/i18n-config/__tests__/metadata.spec.ts b/web/i18n-config/__tests__/metadata.spec.ts
new file mode 100644
index 00000000000..47c88abb817
--- /dev/null
+++ b/web/i18n-config/__tests__/metadata.spec.ts
@@ -0,0 +1,19 @@
+import { getModelLanguage, getPluginLanguage, renderI18nObject } from '../metadata'
+
+describe('localized metadata', () => {
+ it('preserves separate plugin and model language support', () => {
+ expect(getPluginLanguage('pt-BR')).toBe('pt_BR')
+ expect(getPluginLanguage('fr-FR')).toBe('en_US')
+ expect(getModelLanguage('fr-FR')).toBe('fr_FR')
+ expect(getPluginLanguage('zh-Hans')).toBe('zh_Hans')
+ expect(getPluginLanguage('ja-JP')).toBe('ja_JP')
+ })
+
+ it('prefers requested copy, then English, then the first available translation', () => {
+ const copy = { zh_Hans: '中文', en_US: 'English', fr_FR: 'Français' }
+ expect(renderI18nObject(copy, 'fr_FR')).toBe('Français')
+ expect(renderI18nObject(copy, 'ja_JP')).toBe('English')
+ expect(renderI18nObject({ zh_Hans: '', fr_FR: 'Français' }, 'ja_JP')).toBe('Français')
+ expect(renderI18nObject(null, 'en_US')).toBe('')
+ })
+})
diff --git a/web/i18n-config/client.ts b/web/i18n-config/client.ts
index dbc371c19dd..d1234f5c5cd 100644
--- a/web/i18n-config/client.ts
+++ b/web/i18n-config/client.ts
@@ -1,10 +1,12 @@
'use client'
import type { Resource } from 'i18next'
-import type { Locale } from '.'
+import type { Locale } from './locale'
import type { Namespace, NamespaceInFileName } from './resources'
import { createInstance } from 'i18next'
import resourcesToBackend from 'i18next-resources-to-backend'
+import Cookies from 'js-cookie'
import { getI18n, initReactI18next } from 'react-i18next'
+import { LOCALE_COOKIE_NAME } from '@/config'
import { loadI18nResource } from './load-resource'
import { normalizeLocale } from './locale'
import { getInitOptions } from './settings'
@@ -31,3 +33,10 @@ export const changeLanguage = async (lng?: string) => {
const i18n = getI18n()
await i18n.changeLanguage(normalizeLocale(lng))
}
+
+export const setLocaleOnClient = async (locale: string, reloadPage = true) => {
+ const normalized = normalizeLocale(locale)
+ Cookies.set(LOCALE_COOKIE_NAME, normalized, { expires: 365 })
+ await changeLanguage(normalized)
+ if (reloadPage) location.reload()
+}
diff --git a/web/i18n-config/index.ts b/web/i18n-config/index.ts
index 3e67e9484d7..aae1532738c 100644
--- a/web/i18n-config/index.ts
+++ b/web/i18n-config/index.ts
@@ -1,29 +1,5 @@
-import type { Locale } from '@/i18n-config/language'
-import Cookies from 'js-cookie'
-import { LOCALE_COOKIE_NAME } from '@/config'
-import { changeLanguage } from '@/i18n-config/client'
-import { defaultLocale, normalizeLocale, supportedLocales } from './locale'
+import { defaultLocale, supportedLocales } from './locale'
-export const i18n = {
- defaultLocale,
- locales: supportedLocales,
-} as const
+export const i18n = { defaultLocale, locales: supportedLocales } as const
-export type { Locale }
-
-export const setLocaleOnClient = async (locale: string, reloadPage = true) => {
- const normalized = normalizeLocale(locale)
- Cookies.set(LOCALE_COOKIE_NAME, normalized, { expires: 365 })
- await changeLanguage(normalized)
- if (reloadPage) location.reload()
-}
-
-export const renderI18nObject = (
- obj: Record<string, string | null | undefined> | null | undefined,
- language: string,
-) => {
- if (!obj) return ''
- if (obj?.[language]) return obj[language]
- if (obj?.en_US) return obj.en_US
- return Object.values(obj).find((value): value is string => !!value) || ''
-}
+export type { Locale } from './locale'
diff --git a/web/i18n-config/language.ts b/web/i18n-config/language.ts
index dec4f378939..d976b420de9 100644
--- a/web/i18n-config/language.ts
+++ b/web/i18n-config/language.ts
@@ -1,3 +1,4 @@
+import type { Locale } from './locale'
import type { DocLanguage } from '@/types/doc-paths'
import data from './languages'
import { supportedLocales } from './locale'
@@ -6,18 +7,8 @@ export type I18nText = Record<(typeof LanguagesSupported)[number], string>
export const languages = data.languages
-// for compatibility
-export type Locale = 'ja_JP' | 'zh_Hans' | 'en_US' | (typeof languages)[number]['value']
-
export const LanguagesSupported: Locale[] = supportedLocales
-export const getLanguage = (locale: Locale): Locale => {
- // Plugin metadata supports only en_US, zh_Hans, ja_JP, and pt_BR; otherwise use en_US.
- if (['zh-Hans', 'ja-JP', 'pt-BR'].includes(locale)) return locale.replace('-', '_') as Locale
-
- return LanguagesSupported[0]!.replace('-', '_') as Locale
-}
-
const DOC_LANGUAGE: Record<string, DocLanguage | undefined> = {
'zh-Hans': 'zh',
'ja-JP': 'ja',
@@ -32,7 +23,7 @@ const ACCESS_CONTROL_TEMPLATE_LANGUAGE: Record<string, AccessControlTemplateLang
'en-US': 'en',
}
-export const localeMap: Record<Locale, string> = {
+export const localeMap: Record<Locale | 'en_US' | 'zh_Hans' | 'ja_JP', string> = {
'en-US': 'en',
en_US: 'en',
'zh-Hans': 'zh-cn',
diff --git a/web/i18n-config/lib.client.ts b/web/i18n-config/lib.client.ts
index 501737b2748..cbc0f3f4358 100644
--- a/web/i18n-config/lib.client.ts
+++ b/web/i18n-config/lib.client.ts
@@ -1,5 +1,6 @@
'use client'
+import type { Locale } from './locale'
import type { Namespace } from './resources'
import { useTranslation as useTranslationOriginal } from 'react-i18next'
@@ -7,4 +8,7 @@ export function useTranslation<T extends Namespace | undefined = undefined>(ns?:
return useTranslationOriginal(ns)
}
-export { useLocale } from '@/context/i18n'
+export function useLocale(): Locale {
+ const { i18n } = useTranslationOriginal()
+ return i18n.language as Locale
+}
diff --git a/web/i18n-config/locale.ts b/web/i18n-config/locale.ts
index 0b16699b753..bf6244a7db9 100644
--- a/web/i18n-config/locale.ts
+++ b/web/i18n-config/locale.ts
@@ -1,8 +1,8 @@
import data from './languages'
-export type SupportedLocale = (typeof data.languages)[number]['value']
+export type Locale = (typeof data.languages)[number]['value']
-export const defaultLocale = 'en-US' satisfies SupportedLocale
+export const defaultLocale = 'en-US' satisfies Locale
export const supportedLocales = data.languages
.filter((language) => language.supported)
.map((language) => language.value)
@@ -21,7 +21,7 @@ export const canonicalizeLanguageTag = (language: string): string | undefined =>
}
}
-export const normalizeLocale = (language: string): SupportedLocale => {
+export const normalizeLocale = (language: string): Locale => {
const canonical = canonicalizeLanguageTag(language)
return supportedLocales.find((locale) => locale === canonical) ?? defaultLocale
}
diff --git a/web/i18n-config/metadata.ts b/web/i18n-config/metadata.ts
new file mode 100644
index 00000000000..4b9e62cb38a
--- /dev/null
+++ b/web/i18n-config/metadata.ts
@@ -0,0 +1,28 @@
+import type { Locale } from './locale'
+
+export type PluginLanguage = 'en_US' | 'zh_Hans' | 'ja_JP' | 'pt_BR'
+
+export const getPluginLanguage = (locale: Locale): PluginLanguage => {
+ switch (locale) {
+ case 'zh-Hans':
+ return 'zh_Hans'
+ case 'ja-JP':
+ return 'ja_JP'
+ case 'pt-BR':
+ return 'pt_BR'
+ default:
+ return 'en_US'
+ }
+}
+
+export const getModelLanguage = (locale: Locale) => locale.replace('-', '_')
+
+export const renderI18nObject = (
+ obj: Record<string, string | null | undefined> | null | undefined,
+ language: string,
+) => {
+ if (!obj) return ''
+ if (obj?.[language]) return obj[language]
+ if (obj?.en_US) return obj.en_US
+ return Object.values(obj).find((value): value is string => !!value) || ''
+}
diff --git a/web/service/__tests__/use-plugins.spec.tsx b/web/service/__tests__/use-plugins.spec.tsx
index c6b64fdef43..0a8a2a8edce 100644
--- a/web/service/__tests__/use-plugins.spec.tsx
+++ b/web/service/__tests__/use-plugins.spec.tsx
@@ -292,6 +292,16 @@ const createPluginEntity = (): PluginEntity => ({
})
describe('normalizeInstalledPluginDetail', () => {
+ it('preserves Portuguese metadata alongside the existing UI locale spelling', () => {
+ const plugin = createPluginEntity()
+ plugin.declaration.label = { en_US: 'Plugin', pt_BR: 'Extensão' }
+ const detail = normalizeInstalledPluginDetail(plugin)
+
+ expect(detail.declaration.label.pt_BR).toBe('Extensão')
+ expect(detail.declaration.label['pt-BR']).toBe('Extensão')
+ expect(detail.declaration.description.pt_BR).toBe('Plugin description')
+ })
+
it('adapts generic and category list items to the legacy detail model', () => {
const genericDetail = normalizeInstalledPluginDetail(createPluginEntity())
const categoryDetail = normalizeInstalledPluginDetail(
diff --git a/web/service/__tests__/use-triggers.spec.ts b/web/service/__tests__/use-triggers.spec.ts
index b6757e7b821..3699fccce64 100644
--- a/web/service/__tests__/use-triggers.spec.ts
+++ b/web/service/__tests__/use-triggers.spec.ts
@@ -101,6 +101,16 @@ const createGeneratedTriggerProvider = (): GeneratedTriggerProvider => ({
})
describe('trigger provider normalization', () => {
+ it('preserves Portuguese metadata alongside the existing UI locale spelling', () => {
+ const provider = createGeneratedTriggerProvider()
+ provider.label = { en_US: 'Provider', pt_BR: 'Provedor' }
+ const normalized = normalizeTriggerProvider(provider)
+
+ expect(normalized.label.pt_BR).toBe('Provedor')
+ expect(normalized.label['pt-BR']).toBe('Provedor')
+ expect(normalized.description.pt_BR).toBe('GitHub trigger provider')
+ })
+
it('should preserve falsy event parameter defaults', () => {
const normalizedProvider = normalizeTriggerProvider(createGeneratedTriggerProvider())
const triggerWithProvider = convertToTriggerWithProvider(normalizedProvider)
diff --git a/web/service/use-explore.ts b/web/service/use-explore.ts
index c7ca887fbe1..8da10f67f2a 100644
--- a/web/service/use-explore.ts
+++ b/web/service/use-explore.ts
@@ -1,6 +1,6 @@
import type { App, AppCategory } from '@/models/explore'
import { useQuery } from '@tanstack/react-query'
-import { useLocale } from '@/context/i18n'
+import { useLocale } from '#i18n'
import { consoleQuery } from '@/service/console'
import { fetchAppList, fetchLearnDifyAppList } from './explore'
diff --git a/web/service/use-plugins.ts b/web/service/use-plugins.ts
index aae158bf66d..12bb54648b4 100644
--- a/web/service/use-plugins.ts
+++ b/web/service/use-plugins.ts
@@ -133,6 +133,7 @@ const normalizeI18nObject = (
en_US: en,
zh_Hans: zhHans,
ja_JP: ja,
+ pt_BR: ptBr,
}
}
diff --git a/web/service/use-triggers.ts b/web/service/use-triggers.ts
index 02d8225cf3b..e83ace5455a 100644
--- a/web/service/use-triggers.ts
+++ b/web/service/use-triggers.ts
@@ -91,6 +91,7 @@ const normalizeI18nObject = (value: GeneratedI18nObject | null | undefined, fall
en_US: en,
zh_Hans: zhHans,
ja_JP: ja,
+ pt_BR: ptBr,
}
}
@@ -129,6 +130,7 @@ const normalizeUnknownI18nObject = (value: unknown, fallback = '') => {
en_US: en,
zh_Hans: zhHans,
ja_JP: ja,
+ pt_BR: ptBr,
}
}