| 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 = { |
| 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 () => { |
| 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' |
| 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() |
| 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'], |
| 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 = ['问题', '答案'] |
| 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 { |
| 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, |
| 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' |
| 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' |
| 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' |
| } 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' |
| 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 = { |
| 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' |
| 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' |
| 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' | ||||
| 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 = () => { | ||||
| getRulesFromDetail() | getRulesFromDetail() | ||||
| getDefaultMode() | getDefaultMode() | ||||
| } | } | ||||
| // eslint-disable-next-line react-hooks/exhaustive-deps | |||||
| }, []) | }, []) | ||||
| useEffect(() => { | useEffect(() => { |
| 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 |
| 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'], |
| 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' |
| 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 |
| 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' |
| 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 = { |
| 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 |
| 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' |
| 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 = () => { |
| 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 |
| 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 { setLocaleOnClient } from '@/i18n' | |||||
| import type { Locale } from '@/i18n-config' | |||||
| 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' |
| 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' |
| 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 |
| 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' | ||||
| 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) | ||||
| 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 { | ||||
| }, [callback]) | }, [callback]) | ||||
| useEffect(() => { | useEffect(() => { | ||||
| const container = document.getElementById(scrollContainerId) | |||||
| if (container) | if (container) | ||||
| container.addEventListener('scroll', handleScroll) | container.addEventListener('scroll', handleScroll) | ||||
| 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) => { |
| 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) |
| 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' |
| 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 | ||||
| const SearchBox = ({ | const SearchBox = ({ | ||||
| search, | search, | ||||
| onSearchChange, | onSearchChange, | ||||
| wrapperClassName, | |||||
| inputClassName, | inputClassName, | ||||
| tags, | tags, | ||||
| onTagsChange, | onTagsChange, | ||||
| }: 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', |
| 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} |
| 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' | ||||
| 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' |
| 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' | ||||
| 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' |
| 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 { |
| import { LanguagesSupported } from '@/i18n/language' | |||||
| import { LanguagesSupported } from '@/i18n-config/language' | |||||
| import { | import { | ||||
| categoryKeys, | categoryKeys, |
| } 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' |
| 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' | ||||
| 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 |
| 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 = { |
| } 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' |
| 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' | ||||
| } 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' |
| 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' |
| 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 = { |
| 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: { |
| 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' | ||||
| '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[]>([]) |
| 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' |
| 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 type { Locale } from '@/i18n' | |||||
| import { languages } from '@/i18n-config/language' | |||||
| 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' |
| 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' |
| 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' |
| createContext, | createContext, | ||||
| useContext, | useContext, | ||||
| } from 'use-context-selector' | } from 'use-context-selector' | ||||
| import type { Locale } from '@/i18n' | |||||
| import { getDocLanguage, getLanguage, getPricingPageLanguage } from '@/i18n/language' | |||||
| import type { Locale } from '@/i18n-config' | |||||
| import { getDocLanguage, getLanguage, getPricingPageLanguage } from '@/i18n-config/language' | |||||
| import { noop } from 'lodash-es' | import { noop } from 'lodash-es' | ||||
| type II18NContext = { | type II18NContext = { |
| 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() |
| /* 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 |
| /* 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 |
| 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 | ||||
| return resources | return resources | ||||
| } | } | ||||
| const getFallbackTranslation = () => { | |||||
| const resources = NAMESPACES.reduce((acc, ns, index) => { | |||||
| acc[camelCase(NAMESPACES[index])] = require(`./en-US/${ns}`).default | |||||
| /** | |||||
| * !Need to load en-US and zh-Hans resources for initial rendering, which are used in both marketplace and dify | |||||
| * !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, | |||||
| }, | |||||
| } | } | ||||
| } | } | ||||
| .init({ | .init({ | ||||
| lng: undefined, | lng: undefined, | ||||
| fallbackLng: 'en-US', | fallbackLng: 'en-US', | ||||
| resources: { | |||||
| 'en-US': getFallbackTranslation(), | |||||
| }, | |||||
| resources: getInitialTranslations(), | |||||
| }) | }) | ||||
| } | } | ||||
| 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', |
| 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, |
| 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 = { |
| 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 = {} |
| 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, |