fix: Refactor i18n config and fix plugin search box styling issue (#22945)

This commit is contained in:
Wu Tianwei 2025-07-25 15:01:28 +08:00 committed by GitHub
parent 32df3b68c7
commit ad472d59e0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
70 changed files with 96 additions and 85 deletions

View File

@ -1,5 +1,5 @@
import React from 'react' import React from 'react'
import type { Locale } from '@/i18n' import type { Locale } from '@/i18n-config'
import DevelopMain from '@/app/components/develop' import DevelopMain from '@/app/components/develop'
export type IDevelopProps = { export type IDevelopProps = {

View File

@ -1,5 +1,5 @@
import React from 'react' import React from 'react'
import { getLocaleOnServer, useTranslation as translate } from '@/i18n/server' import { getLocaleOnServer, useTranslation as translate } from '@/i18n-config/server'
import Form from '@/app/components/datasets/settings/form' import Form from '@/app/components/datasets/settings/form'
const Settings = async () => { const Settings = async () => {

View File

@ -8,7 +8,7 @@ import TemplateEn from './template/template.en.mdx'
import TemplateZh from './template/template.zh.mdx' import TemplateZh from './template/template.zh.mdx'
import TemplateJa from './template/template.ja.mdx' import TemplateJa from './template/template.ja.mdx'
import I18n from '@/context/i18n' import I18n from '@/context/i18n'
import { LanguagesSupported } from '@/i18n/language' import { LanguagesSupported } from '@/i18n-config/language'
import useTheme from '@/hooks/use-theme' import useTheme from '@/hooks/use-theme'
import { Theme } from '@/types/app' import { Theme } from '@/types/app'
import cn from '@/utils/classnames' import cn from '@/utils/classnames'

View File

@ -1,7 +1,7 @@
import PluginPage from '@/app/components/plugins/plugin-page' import PluginPage from '@/app/components/plugins/plugin-page'
import PluginsPanel from '@/app/components/plugins/plugin-page/plugins-panel' import PluginsPanel from '@/app/components/plugins/plugin-page/plugins-panel'
import Marketplace from '@/app/components/plugins/marketplace' import Marketplace from '@/app/components/plugins/marketplace'
import { getLocaleOnServer } from '@/i18n/server' import { getLocaleOnServer } from '@/i18n-config/server'
const PluginList = async () => { const PluginList = async () => {
const locale = await getLocaleOnServer() const locale = await getLocaleOnServer()

View File

@ -8,7 +8,7 @@ import { useTranslation } from 'react-i18next'
import { useContext } from 'use-context-selector' import { useContext } from 'use-context-selector'
import { Download02 as DownloadIcon } from '@/app/components/base/icons/src/vender/solid/general' import { Download02 as DownloadIcon } from '@/app/components/base/icons/src/vender/solid/general'
import I18n from '@/context/i18n' import I18n from '@/context/i18n'
import { LanguagesSupported } from '@/i18n/language' import { LanguagesSupported } from '@/i18n-config/language'
const CSV_TEMPLATE_QA_EN = [ const CSV_TEMPLATE_QA_EN = [
['question', 'answer'], ['question', 'answer'],

View File

@ -22,7 +22,7 @@ import { ChevronRight } from '@/app/components/base/icons/src/vender/line/arrows
import I18n from '@/context/i18n' import I18n from '@/context/i18n'
import { fetchExportAnnotationList } from '@/service/annotation' import { fetchExportAnnotationList } from '@/service/annotation'
import { LanguagesSupported } from '@/i18n/language' import { LanguagesSupported } from '@/i18n-config/language'
const CSV_HEADER_QA_EN = ['Question', 'Answer'] const CSV_HEADER_QA_EN = ['Question', 'Answer']
const CSV_HEADER_QA_CN = ['问题', '答案'] const CSV_HEADER_QA_CN = ['问题', '答案']

View File

@ -21,7 +21,7 @@ import type { Collection, Tool } from '@/app/components/tools/types'
import { CollectionType } from '@/app/components/tools/types' import { CollectionType } from '@/app/components/tools/types'
import { fetchBuiltInToolList, fetchCustomToolList, fetchModelToolList, fetchWorkflowToolList } from '@/service/tools' import { fetchBuiltInToolList, fetchCustomToolList, fetchModelToolList, fetchWorkflowToolList } from '@/service/tools'
import I18n from '@/context/i18n' import I18n from '@/context/i18n'
import { getLanguage } from '@/i18n/language' import { getLanguage } from '@/i18n-config/language'
import cn from '@/utils/classnames' import cn from '@/utils/classnames'
import type { ToolWithProvider } from '@/app/components/workflow/types' import type { ToolWithProvider } from '@/app/components/workflow/types'
import { import {

View File

@ -12,7 +12,7 @@ import { BookOpen01 } from '@/app/components/base/icons/src/vender/line/educatio
import { fetchCodeBasedExtensionList } from '@/service/common' import { fetchCodeBasedExtensionList } from '@/service/common'
import { SimpleSelect } from '@/app/components/base/select' import { SimpleSelect } from '@/app/components/base/select'
import I18n from '@/context/i18n' import I18n from '@/context/i18n'
import { LanguagesSupported } from '@/i18n/language' import { LanguagesSupported } from '@/i18n-config/language'
import type { import type {
CodeBasedExtensionItem, CodeBasedExtensionItem,
ExternalDataTool, ExternalDataTool,

View File

@ -18,7 +18,7 @@ import { SimpleSelect } from '@/app/components/base/select'
import type { AppDetailResponse } from '@/models/app' import type { AppDetailResponse } from '@/models/app'
import type { AppIconType, AppSSO, Language } from '@/types/app' import type { AppIconType, AppSSO, Language } from '@/types/app'
import { useToastContext } from '@/app/components/base/toast' import { useToastContext } from '@/app/components/base/toast'
import { languages } from '@/i18n/language' import { languages } from '@/i18n-config/language'
import Tooltip from '@/app/components/base/tooltip' import Tooltip from '@/app/components/base/tooltip'
import { useProviderContext } from '@/context/provider-context' import { useProviderContext } from '@/context/provider-context'
import { useModalContext } from '@/context/modal-context' import { useModalContext } from '@/context/modal-context'

View File

@ -35,7 +35,7 @@ import type {
ConversationItem, ConversationItem,
} from '@/models/share' } from '@/models/share'
import { useToastContext } from '@/app/components/base/toast' import { useToastContext } from '@/app/components/base/toast'
import { changeLanguage } from '@/i18n/i18next-config' import { changeLanguage } from '@/i18n-config/i18next-config'
import { useAppFavicon } from '@/hooks/use-app-favicon' import { useAppFavicon } from '@/hooks/use-app-favicon'
import { InputVarType } from '@/app/components/workflow/types' import { InputVarType } from '@/app/components/workflow/types'
import { TransferMethod } from '@/types/app' import { TransferMethod } from '@/types/app'

View File

@ -31,7 +31,7 @@ import type {
ConversationItem, ConversationItem,
} from '@/models/share' } from '@/models/share'
import { useToastContext } from '@/app/components/base/toast' import { useToastContext } from '@/app/components/base/toast'
import { changeLanguage } from '@/i18n/i18next-config' import { changeLanguage } from '@/i18n-config/i18next-config'
import { InputVarType } from '@/app/components/workflow/types' import { InputVarType } from '@/app/components/workflow/types'
import { TransferMethod } from '@/types/app' import { TransferMethod } from '@/types/app'
import { addFileInfos, sortAgentSorts } from '@/app/components/tools/utils' import { addFileInfos, sortAgentSorts } from '@/app/components/tools/utils'

View File

@ -19,7 +19,7 @@ import {
} from '@/service/common' } from '@/service/common'
import type { CodeBasedExtensionItem } from '@/models/common' import type { CodeBasedExtensionItem } from '@/models/common'
import I18n from '@/context/i18n' import I18n from '@/context/i18n'
import { LanguagesSupported } from '@/i18n/language' import { LanguagesSupported } from '@/i18n-config/language'
import { InfoCircle } from '@/app/components/base/icons/src/vender/line/general' import { InfoCircle } from '@/app/components/base/icons/src/vender/line/general'
import { useModalContext } from '@/context/modal-context' import { useModalContext } from '@/context/modal-context'
import { CustomConfigurationStatusEnum } from '@/app/components/header/account-setting/model-provider-page/declarations' import { CustomConfigurationStatusEnum } from '@/app/components/header/account-setting/model-provider-page/declarations'

View File

@ -9,7 +9,7 @@ import VoiceSettings from '@/app/components/base/features/new-feature-panel/text
import { useFeatures, useFeaturesStore } from '@/app/components/base/features/hooks' import { useFeatures, useFeaturesStore } from '@/app/components/base/features/hooks'
import type { OnFeaturesChange } from '@/app/components/base/features/types' import type { OnFeaturesChange } from '@/app/components/base/features/types'
import { FeatureEnum } from '@/app/components/base/features/types' import { FeatureEnum } from '@/app/components/base/features/types'
import { languages } from '@/i18n/language' import { languages } from '@/i18n-config/language'
import { TtsAutoPlay } from '@/types/app' import { TtsAutoPlay } from '@/types/app'
type Props = { type Props = {

View File

@ -13,7 +13,7 @@ import { fetchAppVoices } from '@/service/apps'
import Tooltip from '@/app/components/base/tooltip' import Tooltip from '@/app/components/base/tooltip'
import Switch from '@/app/components/base/switch' import Switch from '@/app/components/base/switch'
import AudioBtn from '@/app/components/base/audio-btn' import AudioBtn from '@/app/components/base/audio-btn'
import { languages } from '@/i18n/language' import { languages } from '@/i18n-config/language'
import { TtsAutoPlay } from '@/types/app' import { TtsAutoPlay } from '@/types/app'
import type { OnFeaturesChange } from '@/app/components/base/features/types' import type { OnFeaturesChange } from '@/app/components/base/features/types'
import classNames from '@/utils/classnames' import classNames from '@/utils/classnames'

View File

@ -14,7 +14,7 @@ import { upload } from '@/service/base'
import { fetchFileUploadConfig } from '@/service/common' import { fetchFileUploadConfig } from '@/service/common'
import { fetchSupportFileTypes } from '@/service/datasets' import { fetchSupportFileTypes } from '@/service/datasets'
import I18n from '@/context/i18n' import I18n from '@/context/i18n'
import { LanguagesSupported } from '@/i18n/language' import { LanguagesSupported } from '@/i18n-config/language'
import { IS_CE_EDITION } from '@/config' import { IS_CE_EDITION } from '@/config'
import { Theme } from '@/types/app' import { Theme } from '@/types/app'
import useTheme from '@/hooks/use-theme' import useTheme from '@/hooks/use-theme'

View File

@ -47,7 +47,7 @@ import I18n from '@/context/i18n'
import { RETRIEVE_METHOD } from '@/types/app' import { RETRIEVE_METHOD } from '@/types/app'
import useBreakpoints, { MediaType } from '@/hooks/use-breakpoints' import useBreakpoints, { MediaType } from '@/hooks/use-breakpoints'
import { useDefaultModel, useModelList, useModelListAndDefaultModelAndCurrentProviderAndModel } from '@/app/components/header/account-setting/model-provider-page/hooks' import { useDefaultModel, useModelList, useModelListAndDefaultModelAndCurrentProviderAndModel } from '@/app/components/header/account-setting/model-provider-page/hooks'
import { LanguagesSupported } from '@/i18n/language' import { LanguagesSupported } from '@/i18n-config/language'
import ModelSelector from '@/app/components/header/account-setting/model-provider-page/model-selector' import ModelSelector from '@/app/components/header/account-setting/model-provider-page/model-selector'
import type { DefaultModel } from '@/app/components/header/account-setting/model-provider-page/declarations' import type { DefaultModel } from '@/app/components/header/account-setting/model-provider-page/declarations'
import { ModelTypeEnum } from '@/app/components/header/account-setting/model-provider-page/declarations' import { ModelTypeEnum } from '@/app/components/header/account-setting/model-provider-page/declarations'
@ -405,7 +405,6 @@ const StepTwo = ({
score_threshold_enabled: false, score_threshold_enabled: false,
score_threshold: 0.5, score_threshold: 0.5,
}) })
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [rerankDefaultModel, isRerankDefaultModelValid]) }, [rerankDefaultModel, isRerankDefaultModelValid])
const getCreationParams = () => { const getCreationParams = () => {
@ -596,7 +595,6 @@ const StepTwo = ({
getRulesFromDetail() getRulesFromDetail()
getDefaultMode() getDefaultMode()
} }
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []) }, [])
useEffect(() => { useEffect(() => {

View File

@ -4,7 +4,7 @@ import React from 'react'
import { RiArrowDownSLine, RiCheckLine } from '@remixicon/react' import { RiArrowDownSLine, RiCheckLine } from '@remixicon/react'
import cn from '@/utils/classnames' import cn from '@/utils/classnames'
import Popover from '@/app/components/base/popover' import Popover from '@/app/components/base/popover'
import { languages } from '@/i18n/language' import { languages } from '@/i18n-config/language'
export type ILanguageSelectProps = { export type ILanguageSelectProps = {
currentLanguage: string currentLanguage: string

View File

@ -9,7 +9,7 @@ import { useContext } from 'use-context-selector'
import { Download02 as DownloadIcon } from '@/app/components/base/icons/src/vender/solid/general' import { Download02 as DownloadIcon } from '@/app/components/base/icons/src/vender/solid/general'
import { ChunkingMode } from '@/models/datasets' import { ChunkingMode } from '@/models/datasets'
import I18n from '@/context/i18n' import I18n from '@/context/i18n'
import { LanguagesSupported } from '@/i18n/language' import { LanguagesSupported } from '@/i18n-config/language'
const CSV_TEMPLATE_QA_EN = [ const CSV_TEMPLATE_QA_EN = [
['question', 'answer'], ['question', 'answer'],

View File

@ -16,7 +16,7 @@ import TemplateChatEn from './template/template_chat.en.mdx'
import TemplateChatZh from './template/template_chat.zh.mdx' import TemplateChatZh from './template/template_chat.zh.mdx'
import TemplateChatJa from './template/template_chat.ja.mdx' import TemplateChatJa from './template/template_chat.ja.mdx'
import I18n from '@/context/i18n' import I18n from '@/context/i18n'
import { LanguagesSupported } from '@/i18n/language' import { LanguagesSupported } from '@/i18n-config/language'
import useTheme from '@/hooks/use-theme' import useTheme from '@/hooks/use-theme'
import { Theme } from '@/types/app' import { Theme } from '@/types/app'
import cn from '@/utils/classnames' import cn from '@/utils/classnames'

View File

@ -10,7 +10,7 @@ import { updateUserProfile } from '@/service/common'
import { ToastContext } from '@/app/components/base/toast' import { ToastContext } from '@/app/components/base/toast'
import I18n from '@/context/i18n' import I18n from '@/context/i18n'
import { timezones } from '@/utils/timezone' import { timezones } from '@/utils/timezone'
import { languages } from '@/i18n/language' import { languages } from '@/i18n-config/language'
const titleClassName = ` const titleClassName = `
mb-2 system-sm-semibold text-text-secondary mb-2 system-sm-semibold text-text-secondary

View File

@ -20,7 +20,7 @@ import { Plan } from '@/app/components/billing/type'
import Button from '@/app/components/base/button' import Button from '@/app/components/base/button'
import UpgradeBtn from '@/app/components/billing/upgrade-btn' import UpgradeBtn from '@/app/components/billing/upgrade-btn'
import { NUM_INFINITE } from '@/app/components/billing/config' import { NUM_INFINITE } from '@/app/components/billing/config'
import { LanguagesSupported } from '@/i18n/language' import { LanguagesSupported } from '@/i18n-config/language'
import cn from '@/utils/classnames' import cn from '@/utils/classnames'
import Tooltip from '@/app/components/base/tooltip' import Tooltip from '@/app/components/base/tooltip'
import { RiPencilLine } from '@remixicon/react' import { RiPencilLine } from '@remixicon/react'

View File

@ -18,7 +18,7 @@ import ProviderCard from '@/app/components/plugins/provider-card'
import List from '@/app/components/plugins/marketplace/list' import List from '@/app/components/plugins/marketplace/list'
import type { Plugin } from '@/app/components/plugins/types' import type { Plugin } from '@/app/components/plugins/types'
import cn from '@/utils/classnames' import cn from '@/utils/classnames'
import { getLocaleOnClient } from '@/i18n' import { getLocaleOnClient } from '@/i18n-config'
import { getMarketplaceUrl } from '@/utils/var' import { getMarketplaceUrl } from '@/utils/var'
type InstallFromMarketplaceProps = { type InstallFromMarketplaceProps = {

View File

@ -7,7 +7,7 @@ import { useLanguage } from '../hooks'
import { Group } from '@/app/components/base/icons/src/vender/other' import { Group } from '@/app/components/base/icons/src/vender/other'
import { OpenaiBlue, OpenaiTeal, OpenaiViolet, OpenaiYellow } from '@/app/components/base/icons/src/public/llm' import { OpenaiBlue, OpenaiTeal, OpenaiViolet, OpenaiYellow } from '@/app/components/base/icons/src/public/llm'
import cn from '@/utils/classnames' import cn from '@/utils/classnames'
import { renderI18nObject } from '@/i18n' import { renderI18nObject } from '@/i18n-config'
type ModelIconProps = { type ModelIconProps = {
provider?: Model | ModelProvider provider?: Model | ModelProvider

View File

@ -3,7 +3,7 @@ import type { ModelProvider } from '../declarations'
import { useLanguage } from '../hooks' import { useLanguage } from '../hooks'
import { Openai } from '@/app/components/base/icons/src/vender/other' import { Openai } from '@/app/components/base/icons/src/vender/other'
import { AnthropicDark, AnthropicLight } from '@/app/components/base/icons/src/public/llm' import { AnthropicDark, AnthropicLight } from '@/app/components/base/icons/src/public/llm'
import { renderI18nObject } from '@/i18n' import { renderI18nObject } from '@/i18n-config'
import { Theme } from '@/types/app' import { Theme } from '@/types/app'
import cn from '@/utils/classnames' import cn from '@/utils/classnames'
import useTheme from '@/hooks/use-theme' import useTheme from '@/hooks/use-theme'

View File

@ -1,6 +1,6 @@
import { useState } from 'react' import { useState } from 'react'
import { X } from '@/app/components/base/icons/src/vender/line/general' import { X } from '@/app/components/base/icons/src/vender/line/general'
import { NOTICE_I18N } from '@/i18n/language' import { NOTICE_I18N } from '@/i18n-config/language'
import { useLanguage } from '@/app/components/header/account-setting/model-provider-page/hooks' import { useLanguage } from '@/app/components/header/account-setting/model-provider-page/hooks'
const MaintenanceNotice = () => { const MaintenanceNotice = () => {

View File

@ -1,7 +1,7 @@
import React from 'react' import React from 'react'
import I18N from './i18n' import I18N from './i18n'
import { ToastProvider } from './base/toast' import { ToastProvider } from './base/toast'
import { getLocaleOnServer } from '@/i18n/server' import { getLocaleOnServer } from '@/i18n-config/server'
export type II18NServerProps = { export type II18NServerProps = {
children: React.ReactNode children: React.ReactNode

View File

@ -3,8 +3,8 @@
import type { FC } from 'react' import type { FC } from 'react'
import React, { useEffect, useState } from 'react' import React, { useEffect, useState } from 'react'
import I18NContext from '@/context/i18n' import I18NContext from '@/context/i18n'
import type { Locale } from '@/i18n' import type { Locale } from '@/i18n-config'
import { setLocaleOnClient } from '@/i18n' import { setLocaleOnClient } from '@/i18n-config'
import Loading from './base/loading' import Loading from './base/loading'
import { usePrefetchQuery } from '@tanstack/react-query' import { usePrefetchQuery } from '@tanstack/react-query'
import { getSystemFeatures } from '@/service/common' import { getSystemFeatures } from '@/service/common'

View File

@ -9,9 +9,9 @@ import Description from './base/description'
import Placeholder from './base/placeholder' import Placeholder from './base/placeholder'
import cn from '@/utils/classnames' import cn from '@/utils/classnames'
import { useGetLanguage } from '@/context/i18n' import { useGetLanguage } from '@/context/i18n'
import { getLanguage } from '@/i18n/language' import { getLanguage } from '@/i18n-config/language'
import { useSingleCategories } from '../hooks' import { useSingleCategories } from '../hooks'
import { renderI18nObject } from '@/i18n' import { renderI18nObject } from '@/i18n-config'
import { useMixedTranslation } from '@/app/components/plugins/marketplace/hooks' import { useMixedTranslation } from '@/app/components/plugins/marketplace/hooks'
import Partner from '../base/badges/partner' import Partner from '../base/badges/partner'
import Verified from '../base/badges/verified' import Verified from '../base/badges/verified'

View File

@ -1,7 +1,7 @@
import { import {
getLocaleOnServer, getLocaleOnServer,
useTranslation as translate, useTranslation as translate,
} from '@/i18n/server' } from '@/i18n-config/server'
type DescriptionProps = { type DescriptionProps = {
locale?: string locale?: string

View File

@ -17,7 +17,7 @@ import {
getFormattedPlugin, getFormattedPlugin,
getMarketplaceCollectionsAndPlugins, getMarketplaceCollectionsAndPlugins,
} from './utils' } from './utils'
import i18n from '@/i18n/i18next-config' import i18n from '@/i18n-config/i18next-config'
import { import {
useMutationPluginsFromMarketplace, useMutationPluginsFromMarketplace,
} from '@/service/use-plugins' } from '@/service/use-plugins'
@ -109,6 +109,7 @@ export const useMarketplacePlugins = () => {
export const useMixedTranslation = (localeFromOuter?: string) => { export const useMixedTranslation = (localeFromOuter?: string) => {
let t = useTranslation().t let t = useTranslation().t
// !localeFromOuter only support zh-Hans and en-US for now
if (localeFromOuter) if (localeFromOuter)
t = i18n.getFixedT(localeFromOuter) t = i18n.getFixedT(localeFromOuter)
@ -121,8 +122,6 @@ export const useMarketplaceContainerScroll = (
callback: () => void, callback: () => void,
scrollContainerId = 'marketplace-container', scrollContainerId = 'marketplace-container',
) => { ) => {
const container = document.getElementById(scrollContainerId)
const handleScroll = useCallback((e: Event) => { const handleScroll = useCallback((e: Event) => {
const target = e.target as HTMLDivElement const target = e.target as HTMLDivElement
const { const {
@ -135,6 +134,7 @@ export const useMarketplaceContainerScroll = (
}, [callback]) }, [callback])
useEffect(() => { useEffect(() => {
const container = document.getElementById(scrollContainerId)
if (container) if (container)
container.addEventListener('scroll', handleScroll) container.addEventListener('scroll', handleScroll)
@ -142,7 +142,7 @@ export const useMarketplaceContainerScroll = (
if (container) if (container)
container.removeEventListener('scroll', handleScroll) container.removeEventListener('scroll', handleScroll)
} }
}, [container, handleScroll]) }, [handleScroll])
} }
export const useSearchBoxAutoAnimate = (searchBoxAutoAnimate?: boolean) => { export const useSearchBoxAutoAnimate = (searchBoxAutoAnimate?: boolean) => {

View File

@ -2,7 +2,7 @@ import { useEffect } from 'react'
import { useMarketplaceContext } from '@/app/components/plugins/marketplace/context' import { useMarketplaceContext } from '@/app/components/plugins/marketplace/context'
export const useScrollIntersection = ( export const useScrollIntersection = (
anchorRef: React.RefObject<HTMLDivElement>, anchorRef: React.RefObject<HTMLDivElement | null>,
intersectionContainerId = 'marketplace-container', intersectionContainerId = 'marketplace-container',
) => { ) => {
const intersected = useMarketplaceContext(v => v.intersected) const intersected = useMarketplaceContext(v => v.intersected)

View File

@ -4,7 +4,7 @@ import { RiArrowRightSLine } from '@remixicon/react'
import type { MarketplaceCollection } from '../types' import type { MarketplaceCollection } from '../types'
import CardWrapper from './card-wrapper' import CardWrapper from './card-wrapper'
import type { Plugin } from '@/app/components/plugins/types' import type { Plugin } from '@/app/components/plugins/types'
import { getLanguage } from '@/i18n/language' import { getLanguage } from '@/i18n-config/language'
import cn from '@/utils/classnames' import cn from '@/utils/classnames'
import type { SearchParamsFromCollection } from '@/app/components/plugins/marketplace/types' import type { SearchParamsFromCollection } from '@/app/components/plugins/marketplace/types'
import { useMixedTranslation } from '@/app/components/plugins/marketplace/hooks' import { useMixedTranslation } from '@/app/components/plugins/marketplace/hooks'

View File

@ -8,6 +8,7 @@ import { RiAddLine } from '@remixicon/react'
type SearchBoxProps = { type SearchBoxProps = {
search: string search: string
onSearchChange: (search: string) => void onSearchChange: (search: string) => void
wrapperClassName?: string
inputClassName?: string inputClassName?: string
tags: string[] tags: string[]
onTagsChange: (tags: string[]) => void onTagsChange: (tags: string[]) => void
@ -21,6 +22,7 @@ type SearchBoxProps = {
const SearchBox = ({ const SearchBox = ({
search, search,
onSearchChange, onSearchChange,
wrapperClassName,
inputClassName, inputClassName,
tags, tags,
onTagsChange, onTagsChange,
@ -32,7 +34,7 @@ const SearchBox = ({
}: SearchBoxProps) => { }: SearchBoxProps) => {
return ( return (
<div <div
className='z-[11] flex items-center' className={cn('z-[11] flex items-center', wrapperClassName)}
> >
<div className={ <div className={
cn('flex items-center', cn('flex items-center',

View File

@ -26,11 +26,12 @@ const SearchBoxWrapper = ({
return ( return (
<SearchBox <SearchBox
inputClassName={cn( wrapperClassName={cn(
'z-[0] mx-auto w-[640px] shrink-0', 'z-[0] mx-auto w-[640px] shrink-0',
searchBoxCanAnimate && 'sticky top-3 z-[11]', searchBoxCanAnimate && 'sticky top-3 z-[11]',
!intersected && searchBoxCanAnimate && 'w-[508px] transition-[width] duration-300', !intersected && searchBoxCanAnimate && 'w-[508px] transition-[width] duration-300',
)} )}
inputClassName='w-full'
search={searchPluginText} search={searchPluginText}
onSearchChange={handleSearchPluginTextChange} onSearchChange={handleSearchPluginTextChange}
tags={filterPluginTags} tags={filterPluginTags}

View File

@ -1,6 +1,6 @@
import React, { useMemo } from 'react' import React, { useMemo } from 'react'
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
import { languages } from '@/i18n/language' import { languages } from '@/i18n-config/language'
import { PortalSelect } from '@/app/components/base/select' import { PortalSelect } from '@/app/components/base/select'
import cn from '@/utils/classnames' import cn from '@/utils/classnames'

View File

@ -14,7 +14,7 @@ import Divider from '@/app/components/base/divider'
import type { import type {
StrategyDetail as StrategyDetailType, StrategyDetail as StrategyDetailType,
} from '@/app/components/plugins/types' } from '@/app/components/plugins/types'
import type { Locale } from '@/i18n' import type { Locale } from '@/i18n-config'
import { useRenderI18nObject } from '@/hooks/use-i18n' import { useRenderI18nObject } from '@/hooks/use-i18n'
import { API_PREFIX } from '@/config' import { API_PREFIX } from '@/config'
import cn from '@/utils/classnames' import cn from '@/utils/classnames'

View File

@ -4,7 +4,7 @@ import StrategyDetailPanel from './strategy-detail'
import type { import type {
StrategyDetail, StrategyDetail,
} from '@/app/components/plugins/types' } from '@/app/components/plugins/types'
import type { Locale } from '@/i18n' import type { Locale } from '@/i18n-config'
import { useRenderI18nObject } from '@/hooks/use-i18n' import { useRenderI18nObject } from '@/hooks/use-i18n'
import cn from '@/utils/classnames' import cn from '@/utils/classnames'

View File

@ -3,7 +3,7 @@ import type { FC } from 'react'
import React from 'react' import React from 'react'
import type { PluginDetail } from '@/app/components/plugins/types' import type { PluginDetail } from '@/app/components/plugins/types'
import Icon from '@/app/components/plugins/card/base/card-icon' import Icon from '@/app/components/plugins/card/base/card-icon'
import { renderI18nObject } from '@/i18n' import { renderI18nObject } from '@/i18n-config'
import { useGetLanguage } from '@/context/i18n' import { useGetLanguage } from '@/context/i18n'
import { MARKETPLACE_API_PREFIX } from '@/config' import { MARKETPLACE_API_PREFIX } from '@/config'
import Checkbox from '@/app/components/base/checkbox' import Checkbox from '@/app/components/base/checkbox'

View File

@ -1,6 +1,6 @@
import type { CredentialFormSchemaBase } from '../header/account-setting/model-provider-page/declarations' import type { CredentialFormSchemaBase } from '../header/account-setting/model-provider-page/declarations'
import type { ToolCredential } from '@/app/components/tools/types' import type { ToolCredential } from '@/app/components/tools/types'
import type { Locale } from '@/i18n' import type { Locale } from '@/i18n-config'
import type { AgentFeature } from '@/app/components/workflow/nodes/agent/types' import type { AgentFeature } from '@/app/components/workflow/nodes/agent/types'
import type { AutoUpdateConfig } from './reference-setting-modal/auto-update-setting/types' import type { AutoUpdateConfig } from './reference-setting-modal/auto-update-setting/types'
export enum PluginType { export enum PluginType {

View File

@ -1,4 +1,4 @@
import { LanguagesSupported } from '@/i18n/language' import { LanguagesSupported } from '@/i18n-config/language'
import { import {
categoryKeys, categoryKeys,

View File

@ -24,7 +24,7 @@ import type {
} from '@/models/debug' } from '@/models/debug'
import AppIcon from '@/app/components/base/app-icon' import AppIcon from '@/app/components/base/app-icon'
import Badge from '@/app/components/base/badge' import Badge from '@/app/components/base/badge'
import { changeLanguage } from '@/i18n/i18next-config' import { changeLanguage } from '@/i18n-config/i18next-config'
import Loading from '@/app/components/base/loading' import Loading from '@/app/components/base/loading'
import { userInputsFormToPromptVariables } from '@/utils/model-config' import { userInputsFormToPromptVariables } from '@/utils/model-config'
import Res from '@/app/components/share/text-generation/result' import Res from '@/app/components/share/text-generation/result'

View File

@ -6,7 +6,7 @@ import { useMount } from 'ahooks'
import cn from '@/utils/classnames' import cn from '@/utils/classnames'
import { Apps02 } from '@/app/components/base/icons/src/vender/line/others' import { Apps02 } from '@/app/components/base/icons/src/vender/line/others'
import I18n from '@/context/i18n' import I18n from '@/context/i18n'
import { getLanguage } from '@/i18n/language' import { getLanguage } from '@/i18n-config/language'
import { useStore as useLabelStore } from '@/app/components/tools/labels/store' import { useStore as useLabelStore } from '@/app/components/tools/labels/store'
import { fetchLabelList } from '@/service/tools' import { fetchLabelList } from '@/service/tools'

View File

@ -11,7 +11,7 @@ import Input from '@/app/components/base/input'
import Drawer from '@/app/components/base/drawer-plus' import Drawer from '@/app/components/base/drawer-plus'
import I18n from '@/context/i18n' import I18n from '@/context/i18n'
import { testAPIAvailable } from '@/service/tools' import { testAPIAvailable } from '@/service/tools'
import { getLanguage } from '@/i18n/language' import { getLanguage } from '@/i18n-config/language'
type Props = { type Props = {
positionCenter?: boolean positionCenter?: boolean

View File

@ -7,7 +7,7 @@ import { useTranslation } from 'react-i18next'
import type { useMarketplace } from './hooks' import type { useMarketplace } from './hooks'
import List from '@/app/components/plugins/marketplace/list' import List from '@/app/components/plugins/marketplace/list'
import Loading from '@/app/components/base/loading' import Loading from '@/app/components/base/loading'
import { getLocaleOnClient } from '@/i18n' import { getLocaleOnClient } from '@/i18n-config'
import { getMarketplaceUrl } from '@/utils/var' import { getMarketplaceUrl } from '@/utils/var'
type MarketplaceProps = { type MarketplaceProps = {

View File

@ -9,7 +9,7 @@ import {
} from '@remixicon/react' } from '@remixicon/react'
import MCPModal from './modal' import MCPModal from './modal'
import I18n from '@/context/i18n' import I18n from '@/context/i18n'
import { getLanguage } from '@/i18n/language' import { getLanguage } from '@/i18n-config/language'
import { useAppContext } from '@/context/app-context' import { useAppContext } from '@/context/app-context'
import { useCreateMCP } from '@/service/use-tools' import { useCreateMCP } from '@/service/use-tools'
import type { ToolWithProvider } from '@/app/components/workflow/types' import type { ToolWithProvider } from '@/app/components/workflow/types'

View File

@ -3,7 +3,7 @@ import React from 'react'
import { useContext } from 'use-context-selector' import { useContext } from 'use-context-selector'
import type { Tool } from '@/app/components/tools/types' import type { Tool } from '@/app/components/tools/types'
import I18n from '@/context/i18n' import I18n from '@/context/i18n'
import { getLanguage } from '@/i18n/language' import { getLanguage } from '@/i18n-config/language'
import Tooltip from '@/app/components/base/tooltip' import Tooltip from '@/app/components/base/tooltip'
import cn from '@/utils/classnames' import cn from '@/utils/classnames'

View File

@ -9,7 +9,7 @@ import {
} from '@remixicon/react' } from '@remixicon/react'
import type { CustomCollectionBackend } from '../types' import type { CustomCollectionBackend } from '../types'
import I18n from '@/context/i18n' import I18n from '@/context/i18n'
import { getLanguage } from '@/i18n/language' import { getLanguage } from '@/i18n-config/language'
import EditCustomToolModal from '@/app/components/tools/edit-custom-collection-modal' import EditCustomToolModal from '@/app/components/tools/edit-custom-collection-modal'
import { createCustomCollection } from '@/service/tools' import { createCustomCollection } from '@/service/tools'
import Toast from '@/app/components/base/toast' import Toast from '@/app/components/base/toast'

View File

@ -11,7 +11,7 @@ import type { Collection, CustomCollectionBackend, Tool, WorkflowToolProviderReq
import ToolItem from './tool-item' import ToolItem from './tool-item'
import cn from '@/utils/classnames' import cn from '@/utils/classnames'
import I18n from '@/context/i18n' import I18n from '@/context/i18n'
import { getLanguage } from '@/i18n/language' import { getLanguage } from '@/i18n-config/language'
import Confirm from '@/app/components/base/confirm' import Confirm from '@/app/components/base/confirm'
import Button from '@/app/components/base/button' import Button from '@/app/components/base/button'
import Indicator from '@/app/components/header/indicator' import Indicator from '@/app/components/header/indicator'

View File

@ -4,7 +4,7 @@ import { useContext } from 'use-context-selector'
import type { Collection, Tool } from '../types' import type { Collection, Tool } from '../types'
import cn from '@/utils/classnames' import cn from '@/utils/classnames'
import I18n from '@/context/i18n' import I18n from '@/context/i18n'
import { getLanguage } from '@/i18n/language' import { getLanguage } from '@/i18n-config/language'
import SettingBuiltInTool from '@/app/components/app/configuration/config/agent/agent-tools/setting-built-in-tool' import SettingBuiltInTool from '@/app/components/app/configuration/config/agent/agent-tools/setting-built-in-tool'
type Props = { type Props = {

View File

@ -3,7 +3,7 @@ import { ALL_CHAT_AVAILABLE_BLOCKS, ALL_COMPLETION_AVAILABLE_BLOCKS } from '@/ap
import type { NodeDefault } from '../../types' import type { NodeDefault } from '../../types'
import type { AgentNodeType } from './types' import type { AgentNodeType } from './types'
import { FormTypeEnum } from '@/app/components/header/account-setting/model-provider-page/declarations' import { FormTypeEnum } from '@/app/components/header/account-setting/model-provider-page/declarations'
import { renderI18nObject } from '@/i18n' import { renderI18nObject } from '@/i18n-config'
const nodeDefault: NodeDefault<AgentNodeType> = { const nodeDefault: NodeDefault<AgentNodeType> = {
defaultValue: { defaultValue: {

View File

@ -13,7 +13,7 @@ import { fetchSupportFileTypes } from '@/service/datasets'
import Field from '@/app/components/workflow/nodes/_base/components/field' import Field from '@/app/components/workflow/nodes/_base/components/field'
import { BlockEnum, type NodePanelProps } from '@/app/components/workflow/types' import { BlockEnum, type NodePanelProps } from '@/app/components/workflow/types'
import I18n from '@/context/i18n' import I18n from '@/context/i18n'
import { LanguagesSupported } from '@/i18n/language' import { LanguagesSupported } from '@/i18n-config/language'
const i18nPrefix = 'workflow.nodes.docExtractor' const i18nPrefix = 'workflow.nodes.docExtractor'

View File

@ -1,8 +1,8 @@
'use client' 'use client'
import { loadLangResources } from '@/i18n/i18next-config' import { loadLangResources } from '@/i18n-config/i18next-config'
import { useCallback, useEffect, useState } from 'react' import { useCallback, useEffect, useState } from 'react'
import cn from '@/utils/classnames' import cn from '@/utils/classnames'
import { LanguagesSupported } from '@/i18n/language' import { LanguagesSupported } from '@/i18n-config/language'
export default function I18nTest() { export default function I18nTest() {
const [langs, setLangs] = useState<Lang[]>([]) const [langs, setLangs] = useState<Lang[]>([])

View File

@ -3,7 +3,7 @@ import type { Viewport } from 'next'
import I18nServer from './components/i18n-server' import I18nServer from './components/i18n-server'
import BrowserInitializer from './components/browser-initializer' import BrowserInitializer from './components/browser-initializer'
import SentryInitializer from './components/sentry-initializer' import SentryInitializer from './components/sentry-initializer'
import { getLocaleOnServer } from '@/i18n/server' import { getLocaleOnServer } from '@/i18n-config/server'
import { TanstackQueryInitializer } from '@/context/query-client' import { TanstackQueryInitializer } from '@/context/query-client'
import { ThemeProvider } from 'next-themes' import { ThemeProvider } from 'next-themes'
import './styles/globals.css' import './styles/globals.css'

View File

@ -3,8 +3,8 @@ import React from 'react'
import { useContext } from 'use-context-selector' import { useContext } from 'use-context-selector'
import Select from '@/app/components/base/select/locale' import Select from '@/app/components/base/select/locale'
import Divider from '@/app/components/base/divider' import Divider from '@/app/components/base/divider'
import { languages } from '@/i18n/language' import { languages } from '@/i18n-config/language'
import type { Locale } from '@/i18n' import type { Locale } from '@/i18n-config'
import I18n from '@/context/i18n' import I18n from '@/context/i18n'
import dynamic from 'next/dynamic' import dynamic from 'next/dynamic'
import { useGlobalPublicStore } from '@/context/global-public-context' import { useGlobalPublicStore } from '@/context/global-public-context'

View File

@ -11,7 +11,7 @@ import Input from '@/app/components/base/input'
import { SimpleSelect } from '@/app/components/base/select' import { SimpleSelect } from '@/app/components/base/select'
import Button from '@/app/components/base/button' import Button from '@/app/components/base/button'
import { timezones } from '@/utils/timezone' import { timezones } from '@/utils/timezone'
import { LanguagesSupported, languages } from '@/i18n/language' import { LanguagesSupported, languages } from '@/i18n-config/language'
import I18n from '@/context/i18n' import I18n from '@/context/i18n'
import { activateMember, invitationCheck } from '@/service/common' import { activateMember, invitationCheck } from '@/service/common'
import Loading from '@/app/components/base/loading' import Loading from '@/app/components/base/loading'

View File

@ -9,7 +9,7 @@ import Button from '@/app/components/base/button'
import Tooltip from '@/app/components/base/tooltip' import Tooltip from '@/app/components/base/tooltip'
import { SimpleSelect } from '@/app/components/base/select' import { SimpleSelect } from '@/app/components/base/select'
import { timezones } from '@/utils/timezone' import { timezones } from '@/utils/timezone'
import { LanguagesSupported, languages } from '@/i18n/language' import { LanguagesSupported, languages } from '@/i18n-config/language'
import { oneMoreStep } from '@/service/common' import { oneMoreStep } from '@/service/common'
import Toast from '@/app/components/base/toast' import Toast from '@/app/components/base/toast'
import { useDocLink } from '@/context/i18n' import { useDocLink } from '@/context/i18n'

View File

@ -2,8 +2,8 @@ import {
createContext, createContext,
useContext, useContext,
} from 'use-context-selector' } from 'use-context-selector'
import type { Locale } from '@/i18n' import type { Locale } from '@/i18n-config'
import { getDocLanguage, getLanguage, getPricingPageLanguage } from '@/i18n/language' import { getDocLanguage, getLanguage, getPricingPageLanguage } from '@/i18n-config/language'
import { noop } from 'lodash-es' import { noop } from 'lodash-es'
type II18NContext = { type II18NContext = {

View File

@ -1,5 +1,5 @@
import { useLanguage } from '@/app/components/header/account-setting/model-provider-page/hooks' import { useLanguage } from '@/app/components/header/account-setting/model-provider-page/hooks'
import { renderI18nObject } from '@/i18n' import { renderI18nObject } from '@/i18n-config'
export const useRenderI18nObject = () => { export const useRenderI18nObject = () => {
const language = useLanguage() const language = useLanguage()

View File

@ -1,4 +1,3 @@
/* eslint-disable no-eval */
const fs = require('node:fs') const fs = require('node:fs')
const path = require('node:path') const path = require('node:path')
const transpile = require('typescript').transpile const transpile = require('typescript').transpile

View File

@ -1,4 +1,3 @@
/* eslint-disable no-eval */
const fs = require('node:fs') const fs = require('node:fs')
const path = require('node:path') const path = require('node:path')
const transpile = require('typescript').transpile const transpile = require('typescript').transpile

View File

@ -6,10 +6,10 @@ import { initReactI18next } from 'react-i18next'
const requireSilent = async (lang: string, namespace: string) => { const requireSilent = async (lang: string, namespace: string) => {
let res let res
try { try {
res = (await import(`./${lang}/${namespace}`)).default res = (await import(`../i18n/${lang}/${namespace}`)).default
} }
catch { catch {
res = (await import(`./en-US/${namespace}`)).default res = (await import(`../i18n/en-US/${namespace}`)).default
} }
return res return res
@ -53,13 +53,27 @@ export const loadLangResources = async (lang: string) => {
return resources return resources
} }
const getFallbackTranslation = () => { /**
const resources = NAMESPACES.reduce((acc, ns, index) => { * !Need to load en-US and zh-Hans resources for initial rendering, which are used in both marketplace and dify
acc[camelCase(NAMESPACES[index])] = require(`./en-US/${ns}`).default * !Other languages will be loaded on demand
* !This is to avoid loading all languages at once which can be slow
*/
const getInitialTranslations = () => {
const en_USResources = NAMESPACES.reduce((acc, ns, index) => {
acc[camelCase(NAMESPACES[index])] = require(`../i18n/en-US/${ns}`).default
return acc
}, {} as Record<string, any>)
const zh_HansResources = NAMESPACES.reduce((acc, ns, index) => {
acc[camelCase(NAMESPACES[index])] = require(`../i18n/zh-Hans/${ns}`).default
return acc return acc
}, {} as Record<string, any>) }, {} as Record<string, any>)
return { return {
translation: resources, 'en-US': {
translation: en_USResources,
},
'zh-Hans': {
translation: zh_HansResources,
},
} }
} }
@ -68,9 +82,7 @@ if (!i18n.isInitialized) {
.init({ .init({
lng: undefined, lng: undefined,
fallbackLng: 'en-US', fallbackLng: 'en-US',
resources: { resources: getInitialTranslations(),
'en-US': getFallbackTranslation(),
},
}) })
} }

View File

@ -1,8 +1,8 @@
import Cookies from 'js-cookie' import Cookies from 'js-cookie'
import { changeLanguage } from '@/i18n/i18next-config' import { changeLanguage } from '@/i18n-config/i18next-config'
import { LOCALE_COOKIE_NAME } from '@/config' import { LOCALE_COOKIE_NAME } from '@/config'
import { LanguagesSupported } from '@/i18n/language' import { LanguagesSupported } from '@/i18n-config/language'
export const i18n = { export const i18n = {
defaultLocale: 'en-US', defaultLocale: 'en-US',

View File

@ -13,7 +13,7 @@ const initI18next = async (lng: Locale, ns: string) => {
const i18nInstance = createInstance() const i18nInstance = createInstance()
await i18nInstance await i18nInstance
.use(initReactI18next) .use(initReactI18next)
.use(resourcesToBackend((language: string, namespace: string) => import(`./${language}/${namespace}.ts`))) .use(resourcesToBackend((language: string, namespace: string) => import(`../i18n/${language}/${namespace}.ts`)))
.init({ .init({
lng: lng === 'zh-Hans' ? 'zh-Hans' : lng, lng: lng === 'zh-Hans' ? 'zh-Hans' : lng,
ns, ns,

View File

@ -1,4 +1,4 @@
import type { I18nText } from '@/i18n/language' import type { I18nText } from '@/i18n-config/language'
import type { Model } from '@/types/app' import type { Model } from '@/types/app'
export type CommonResponse = { export type CommonResponse = {

View File

@ -1,4 +1,4 @@
import type { Locale } from '@/i18n' import type { Locale } from '@/i18n-config'
import type { AppIconType } from '@/types/app' import type { AppIconType } from '@/types/app'
export type ResponseHolder = {} export type ResponseHolder = {}

View File

@ -1,6 +1,6 @@
import type { AnnotationReplyConfig, ChatPromptConfig, CompletionPromptConfig, DatasetConfigs, PromptMode } from '@/models/debug' import type { AnnotationReplyConfig, ChatPromptConfig, CompletionPromptConfig, DatasetConfigs, PromptMode } from '@/models/debug'
import type { CollectionType } from '@/app/components/tools/types' import type { CollectionType } from '@/app/components/tools/types'
import type { LanguagesSupported } from '@/i18n/language' import type { LanguagesSupported } from '@/i18n-config/language'
import type { Tag } from '@/app/components/base/tag-management/constant' import type { Tag } from '@/app/components/base/tag-management/constant'
import type { import type {
RerankingModeEnum, RerankingModeEnum,