| @@ -1,5 +1,5 @@ | |||
| import React from 'react' | |||
| import type { Locale } from '@/i18n' | |||
| import type { Locale } from '@/i18n-config' | |||
| import DevelopMain from '@/app/components/develop' | |||
| export type IDevelopProps = { | |||
| @@ -1,5 +1,5 @@ | |||
| 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' | |||
| const Settings = async () => { | |||
| @@ -8,7 +8,7 @@ import TemplateEn from './template/template.en.mdx' | |||
| import TemplateZh from './template/template.zh.mdx' | |||
| import TemplateJa from './template/template.ja.mdx' | |||
| import I18n from '@/context/i18n' | |||
| import { LanguagesSupported } from '@/i18n/language' | |||
| import { LanguagesSupported } from '@/i18n-config/language' | |||
| import useTheme from '@/hooks/use-theme' | |||
| import { Theme } from '@/types/app' | |||
| import cn from '@/utils/classnames' | |||
| @@ -1,7 +1,7 @@ | |||
| import PluginPage from '@/app/components/plugins/plugin-page' | |||
| import PluginsPanel from '@/app/components/plugins/plugin-page/plugins-panel' | |||
| import Marketplace from '@/app/components/plugins/marketplace' | |||
| import { getLocaleOnServer } from '@/i18n/server' | |||
| import { getLocaleOnServer } from '@/i18n-config/server' | |||
| const PluginList = async () => { | |||
| const locale = await getLocaleOnServer() | |||
| @@ -8,7 +8,7 @@ import { useTranslation } from 'react-i18next' | |||
| import { useContext } from 'use-context-selector' | |||
| import { Download02 as DownloadIcon } from '@/app/components/base/icons/src/vender/solid/general' | |||
| import I18n from '@/context/i18n' | |||
| import { LanguagesSupported } from '@/i18n/language' | |||
| import { LanguagesSupported } from '@/i18n-config/language' | |||
| const CSV_TEMPLATE_QA_EN = [ | |||
| ['question', 'answer'], | |||
| @@ -22,7 +22,7 @@ import { ChevronRight } from '@/app/components/base/icons/src/vender/line/arrows | |||
| import I18n from '@/context/i18n' | |||
| 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_CN = ['问题', '答案'] | |||
| @@ -21,7 +21,7 @@ import type { Collection, Tool } from '@/app/components/tools/types' | |||
| import { CollectionType } from '@/app/components/tools/types' | |||
| import { fetchBuiltInToolList, fetchCustomToolList, fetchModelToolList, fetchWorkflowToolList } from '@/service/tools' | |||
| import I18n from '@/context/i18n' | |||
| import { getLanguage } from '@/i18n/language' | |||
| import { getLanguage } from '@/i18n-config/language' | |||
| import cn from '@/utils/classnames' | |||
| import type { ToolWithProvider } from '@/app/components/workflow/types' | |||
| import { | |||
| @@ -12,7 +12,7 @@ import { BookOpen01 } from '@/app/components/base/icons/src/vender/line/educatio | |||
| import { fetchCodeBasedExtensionList } from '@/service/common' | |||
| import { SimpleSelect } from '@/app/components/base/select' | |||
| import I18n from '@/context/i18n' | |||
| import { LanguagesSupported } from '@/i18n/language' | |||
| import { LanguagesSupported } from '@/i18n-config/language' | |||
| import type { | |||
| CodeBasedExtensionItem, | |||
| ExternalDataTool, | |||
| @@ -18,7 +18,7 @@ import { SimpleSelect } from '@/app/components/base/select' | |||
| import type { AppDetailResponse } from '@/models/app' | |||
| import type { AppIconType, AppSSO, Language } from '@/types/app' | |||
| 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 { useProviderContext } from '@/context/provider-context' | |||
| import { useModalContext } from '@/context/modal-context' | |||
| @@ -35,7 +35,7 @@ import type { | |||
| ConversationItem, | |||
| } from '@/models/share' | |||
| 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 { InputVarType } from '@/app/components/workflow/types' | |||
| import { TransferMethod } from '@/types/app' | |||
| @@ -31,7 +31,7 @@ import type { | |||
| ConversationItem, | |||
| } from '@/models/share' | |||
| 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 { TransferMethod } from '@/types/app' | |||
| import { addFileInfos, sortAgentSorts } from '@/app/components/tools/utils' | |||
| @@ -19,7 +19,7 @@ import { | |||
| } from '@/service/common' | |||
| import type { CodeBasedExtensionItem } from '@/models/common' | |||
| 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 { useModalContext } from '@/context/modal-context' | |||
| import { CustomConfigurationStatusEnum } from '@/app/components/header/account-setting/model-provider-page/declarations' | |||
| @@ -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 type { OnFeaturesChange } 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' | |||
| type Props = { | |||
| @@ -13,7 +13,7 @@ import { fetchAppVoices } from '@/service/apps' | |||
| import Tooltip from '@/app/components/base/tooltip' | |||
| import Switch from '@/app/components/base/switch' | |||
| 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 type { OnFeaturesChange } from '@/app/components/base/features/types' | |||
| import classNames from '@/utils/classnames' | |||
| @@ -14,7 +14,7 @@ import { upload } from '@/service/base' | |||
| import { fetchFileUploadConfig } from '@/service/common' | |||
| import { fetchSupportFileTypes } from '@/service/datasets' | |||
| import I18n from '@/context/i18n' | |||
| import { LanguagesSupported } from '@/i18n/language' | |||
| import { LanguagesSupported } from '@/i18n-config/language' | |||
| import { IS_CE_EDITION } from '@/config' | |||
| import { Theme } from '@/types/app' | |||
| import useTheme from '@/hooks/use-theme' | |||
| @@ -47,7 +47,7 @@ import I18n from '@/context/i18n' | |||
| import { RETRIEVE_METHOD } from '@/types/app' | |||
| import useBreakpoints, { MediaType } from '@/hooks/use-breakpoints' | |||
| 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 type { DefaultModel } 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: 0.5, | |||
| }) | |||
| // eslint-disable-next-line react-hooks/exhaustive-deps | |||
| }, [rerankDefaultModel, isRerankDefaultModelValid]) | |||
| const getCreationParams = () => { | |||
| @@ -596,7 +595,6 @@ const StepTwo = ({ | |||
| getRulesFromDetail() | |||
| getDefaultMode() | |||
| } | |||
| // eslint-disable-next-line react-hooks/exhaustive-deps | |||
| }, []) | |||
| useEffect(() => { | |||
| @@ -4,7 +4,7 @@ import React from 'react' | |||
| import { RiArrowDownSLine, RiCheckLine } from '@remixicon/react' | |||
| import cn from '@/utils/classnames' | |||
| import Popover from '@/app/components/base/popover' | |||
| import { languages } from '@/i18n/language' | |||
| import { languages } from '@/i18n-config/language' | |||
| export type ILanguageSelectProps = { | |||
| currentLanguage: string | |||
| @@ -9,7 +9,7 @@ import { useContext } from 'use-context-selector' | |||
| import { Download02 as DownloadIcon } from '@/app/components/base/icons/src/vender/solid/general' | |||
| import { ChunkingMode } from '@/models/datasets' | |||
| import I18n from '@/context/i18n' | |||
| import { LanguagesSupported } from '@/i18n/language' | |||
| import { LanguagesSupported } from '@/i18n-config/language' | |||
| const CSV_TEMPLATE_QA_EN = [ | |||
| ['question', 'answer'], | |||
| @@ -16,7 +16,7 @@ import TemplateChatEn from './template/template_chat.en.mdx' | |||
| import TemplateChatZh from './template/template_chat.zh.mdx' | |||
| import TemplateChatJa from './template/template_chat.ja.mdx' | |||
| import I18n from '@/context/i18n' | |||
| import { LanguagesSupported } from '@/i18n/language' | |||
| import { LanguagesSupported } from '@/i18n-config/language' | |||
| import useTheme from '@/hooks/use-theme' | |||
| import { Theme } from '@/types/app' | |||
| import cn from '@/utils/classnames' | |||
| @@ -10,7 +10,7 @@ import { updateUserProfile } from '@/service/common' | |||
| import { ToastContext } from '@/app/components/base/toast' | |||
| import I18n from '@/context/i18n' | |||
| import { timezones } from '@/utils/timezone' | |||
| import { languages } from '@/i18n/language' | |||
| import { languages } from '@/i18n-config/language' | |||
| const titleClassName = ` | |||
| mb-2 system-sm-semibold text-text-secondary | |||
| @@ -20,7 +20,7 @@ import { Plan } from '@/app/components/billing/type' | |||
| import Button from '@/app/components/base/button' | |||
| import UpgradeBtn from '@/app/components/billing/upgrade-btn' | |||
| 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 Tooltip from '@/app/components/base/tooltip' | |||
| import { RiPencilLine } from '@remixicon/react' | |||
| @@ -18,7 +18,7 @@ import ProviderCard from '@/app/components/plugins/provider-card' | |||
| import List from '@/app/components/plugins/marketplace/list' | |||
| import type { Plugin } from '@/app/components/plugins/types' | |||
| import cn from '@/utils/classnames' | |||
| import { getLocaleOnClient } from '@/i18n' | |||
| import { getLocaleOnClient } from '@/i18n-config' | |||
| import { getMarketplaceUrl } from '@/utils/var' | |||
| type InstallFromMarketplaceProps = { | |||
| @@ -7,7 +7,7 @@ import { useLanguage } from '../hooks' | |||
| import { Group } from '@/app/components/base/icons/src/vender/other' | |||
| import { OpenaiBlue, OpenaiTeal, OpenaiViolet, OpenaiYellow } from '@/app/components/base/icons/src/public/llm' | |||
| import cn from '@/utils/classnames' | |||
| import { renderI18nObject } from '@/i18n' | |||
| import { renderI18nObject } from '@/i18n-config' | |||
| type ModelIconProps = { | |||
| provider?: Model | ModelProvider | |||
| @@ -3,7 +3,7 @@ import type { ModelProvider } from '../declarations' | |||
| import { useLanguage } from '../hooks' | |||
| import { Openai } from '@/app/components/base/icons/src/vender/other' | |||
| 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 cn from '@/utils/classnames' | |||
| import useTheme from '@/hooks/use-theme' | |||
| @@ -1,6 +1,6 @@ | |||
| import { useState } from 'react' | |||
| 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' | |||
| const MaintenanceNotice = () => { | |||
| @@ -1,7 +1,7 @@ | |||
| import React from 'react' | |||
| import I18N from './i18n' | |||
| import { ToastProvider } from './base/toast' | |||
| import { getLocaleOnServer } from '@/i18n/server' | |||
| import { getLocaleOnServer } from '@/i18n-config/server' | |||
| export type II18NServerProps = { | |||
| children: React.ReactNode | |||
| @@ -3,8 +3,8 @@ | |||
| import type { FC } from 'react' | |||
| import React, { useEffect, useState } from 'react' | |||
| 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 { usePrefetchQuery } from '@tanstack/react-query' | |||
| import { getSystemFeatures } from '@/service/common' | |||
| @@ -9,9 +9,9 @@ import Description from './base/description' | |||
| import Placeholder from './base/placeholder' | |||
| import cn from '@/utils/classnames' | |||
| import { useGetLanguage } from '@/context/i18n' | |||
| import { getLanguage } from '@/i18n/language' | |||
| import { getLanguage } from '@/i18n-config/language' | |||
| import { useSingleCategories } from '../hooks' | |||
| import { renderI18nObject } from '@/i18n' | |||
| import { renderI18nObject } from '@/i18n-config' | |||
| import { useMixedTranslation } from '@/app/components/plugins/marketplace/hooks' | |||
| import Partner from '../base/badges/partner' | |||
| import Verified from '../base/badges/verified' | |||
| @@ -1,7 +1,7 @@ | |||
| import { | |||
| getLocaleOnServer, | |||
| useTranslation as translate, | |||
| } from '@/i18n/server' | |||
| } from '@/i18n-config/server' | |||
| type DescriptionProps = { | |||
| locale?: string | |||
| @@ -17,7 +17,7 @@ import { | |||
| getFormattedPlugin, | |||
| getMarketplaceCollectionsAndPlugins, | |||
| } from './utils' | |||
| import i18n from '@/i18n/i18next-config' | |||
| import i18n from '@/i18n-config/i18next-config' | |||
| import { | |||
| useMutationPluginsFromMarketplace, | |||
| } from '@/service/use-plugins' | |||
| @@ -109,6 +109,7 @@ export const useMarketplacePlugins = () => { | |||
| export const useMixedTranslation = (localeFromOuter?: string) => { | |||
| let t = useTranslation().t | |||
| // !localeFromOuter only support zh-Hans and en-US for now | |||
| if (localeFromOuter) | |||
| t = i18n.getFixedT(localeFromOuter) | |||
| @@ -121,8 +122,6 @@ export const useMarketplaceContainerScroll = ( | |||
| callback: () => void, | |||
| scrollContainerId = 'marketplace-container', | |||
| ) => { | |||
| const container = document.getElementById(scrollContainerId) | |||
| const handleScroll = useCallback((e: Event) => { | |||
| const target = e.target as HTMLDivElement | |||
| const { | |||
| @@ -135,6 +134,7 @@ export const useMarketplaceContainerScroll = ( | |||
| }, [callback]) | |||
| useEffect(() => { | |||
| const container = document.getElementById(scrollContainerId) | |||
| if (container) | |||
| container.addEventListener('scroll', handleScroll) | |||
| @@ -142,7 +142,7 @@ export const useMarketplaceContainerScroll = ( | |||
| if (container) | |||
| container.removeEventListener('scroll', handleScroll) | |||
| } | |||
| }, [container, handleScroll]) | |||
| }, [handleScroll]) | |||
| } | |||
| export const useSearchBoxAutoAnimate = (searchBoxAutoAnimate?: boolean) => { | |||
| @@ -2,7 +2,7 @@ import { useEffect } from 'react' | |||
| import { useMarketplaceContext } from '@/app/components/plugins/marketplace/context' | |||
| export const useScrollIntersection = ( | |||
| anchorRef: React.RefObject<HTMLDivElement>, | |||
| anchorRef: React.RefObject<HTMLDivElement | null>, | |||
| intersectionContainerId = 'marketplace-container', | |||
| ) => { | |||
| const intersected = useMarketplaceContext(v => v.intersected) | |||
| @@ -4,7 +4,7 @@ import { RiArrowRightSLine } from '@remixicon/react' | |||
| import type { MarketplaceCollection } from '../types' | |||
| import CardWrapper from './card-wrapper' | |||
| 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 type { SearchParamsFromCollection } from '@/app/components/plugins/marketplace/types' | |||
| import { useMixedTranslation } from '@/app/components/plugins/marketplace/hooks' | |||
| @@ -8,6 +8,7 @@ import { RiAddLine } from '@remixicon/react' | |||
| type SearchBoxProps = { | |||
| search: string | |||
| onSearchChange: (search: string) => void | |||
| wrapperClassName?: string | |||
| inputClassName?: string | |||
| tags: string[] | |||
| onTagsChange: (tags: string[]) => void | |||
| @@ -21,6 +22,7 @@ type SearchBoxProps = { | |||
| const SearchBox = ({ | |||
| search, | |||
| onSearchChange, | |||
| wrapperClassName, | |||
| inputClassName, | |||
| tags, | |||
| onTagsChange, | |||
| @@ -32,7 +34,7 @@ const SearchBox = ({ | |||
| }: SearchBoxProps) => { | |||
| return ( | |||
| <div | |||
| className='z-[11] flex items-center' | |||
| className={cn('z-[11] flex items-center', wrapperClassName)} | |||
| > | |||
| <div className={ | |||
| cn('flex items-center', | |||
| @@ -26,11 +26,12 @@ const SearchBoxWrapper = ({ | |||
| return ( | |||
| <SearchBox | |||
| inputClassName={cn( | |||
| wrapperClassName={cn( | |||
| 'z-[0] mx-auto w-[640px] shrink-0', | |||
| searchBoxCanAnimate && 'sticky top-3 z-[11]', | |||
| !intersected && searchBoxCanAnimate && 'w-[508px] transition-[width] duration-300', | |||
| )} | |||
| inputClassName='w-full' | |||
| search={searchPluginText} | |||
| onSearchChange={handleSearchPluginTextChange} | |||
| tags={filterPluginTags} | |||
| @@ -1,6 +1,6 @@ | |||
| import React, { useMemo } from 'react' | |||
| import { useTranslation } from 'react-i18next' | |||
| import { languages } from '@/i18n/language' | |||
| import { languages } from '@/i18n-config/language' | |||
| import { PortalSelect } from '@/app/components/base/select' | |||
| import cn from '@/utils/classnames' | |||
| @@ -14,7 +14,7 @@ import Divider from '@/app/components/base/divider' | |||
| import type { | |||
| StrategyDetail as StrategyDetailType, | |||
| } from '@/app/components/plugins/types' | |||
| import type { Locale } from '@/i18n' | |||
| import type { Locale } from '@/i18n-config' | |||
| import { useRenderI18nObject } from '@/hooks/use-i18n' | |||
| import { API_PREFIX } from '@/config' | |||
| import cn from '@/utils/classnames' | |||
| @@ -4,7 +4,7 @@ import StrategyDetailPanel from './strategy-detail' | |||
| import type { | |||
| StrategyDetail, | |||
| } from '@/app/components/plugins/types' | |||
| import type { Locale } from '@/i18n' | |||
| import type { Locale } from '@/i18n-config' | |||
| import { useRenderI18nObject } from '@/hooks/use-i18n' | |||
| import cn from '@/utils/classnames' | |||
| @@ -3,7 +3,7 @@ import type { FC } from 'react' | |||
| import React from 'react' | |||
| import type { PluginDetail } from '@/app/components/plugins/types' | |||
| 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 { MARKETPLACE_API_PREFIX } from '@/config' | |||
| import Checkbox from '@/app/components/base/checkbox' | |||
| @@ -1,6 +1,6 @@ | |||
| import type { CredentialFormSchemaBase } from '../header/account-setting/model-provider-page/declarations' | |||
| 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 { AutoUpdateConfig } from './reference-setting-modal/auto-update-setting/types' | |||
| export enum PluginType { | |||
| @@ -1,4 +1,4 @@ | |||
| import { LanguagesSupported } from '@/i18n/language' | |||
| import { LanguagesSupported } from '@/i18n-config/language' | |||
| import { | |||
| categoryKeys, | |||
| @@ -24,7 +24,7 @@ import type { | |||
| } from '@/models/debug' | |||
| import AppIcon from '@/app/components/base/app-icon' | |||
| 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 { userInputsFormToPromptVariables } from '@/utils/model-config' | |||
| import Res from '@/app/components/share/text-generation/result' | |||
| @@ -6,7 +6,7 @@ import { useMount } from 'ahooks' | |||
| import cn from '@/utils/classnames' | |||
| import { Apps02 } from '@/app/components/base/icons/src/vender/line/others' | |||
| 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 { fetchLabelList } from '@/service/tools' | |||
| @@ -11,7 +11,7 @@ import Input from '@/app/components/base/input' | |||
| import Drawer from '@/app/components/base/drawer-plus' | |||
| import I18n from '@/context/i18n' | |||
| import { testAPIAvailable } from '@/service/tools' | |||
| import { getLanguage } from '@/i18n/language' | |||
| import { getLanguage } from '@/i18n-config/language' | |||
| type Props = { | |||
| positionCenter?: boolean | |||
| @@ -7,7 +7,7 @@ import { useTranslation } from 'react-i18next' | |||
| import type { useMarketplace } from './hooks' | |||
| import List from '@/app/components/plugins/marketplace/list' | |||
| import Loading from '@/app/components/base/loading' | |||
| import { getLocaleOnClient } from '@/i18n' | |||
| import { getLocaleOnClient } from '@/i18n-config' | |||
| import { getMarketplaceUrl } from '@/utils/var' | |||
| type MarketplaceProps = { | |||
| @@ -9,7 +9,7 @@ import { | |||
| } from '@remixicon/react' | |||
| import MCPModal from './modal' | |||
| import I18n from '@/context/i18n' | |||
| import { getLanguage } from '@/i18n/language' | |||
| import { getLanguage } from '@/i18n-config/language' | |||
| import { useAppContext } from '@/context/app-context' | |||
| import { useCreateMCP } from '@/service/use-tools' | |||
| import type { ToolWithProvider } from '@/app/components/workflow/types' | |||
| @@ -3,7 +3,7 @@ import React from 'react' | |||
| import { useContext } from 'use-context-selector' | |||
| import type { Tool } from '@/app/components/tools/types' | |||
| import I18n from '@/context/i18n' | |||
| import { getLanguage } from '@/i18n/language' | |||
| import { getLanguage } from '@/i18n-config/language' | |||
| import Tooltip from '@/app/components/base/tooltip' | |||
| import cn from '@/utils/classnames' | |||
| @@ -9,7 +9,7 @@ import { | |||
| } from '@remixicon/react' | |||
| import type { CustomCollectionBackend } from '../types' | |||
| 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 { createCustomCollection } from '@/service/tools' | |||
| import Toast from '@/app/components/base/toast' | |||
| @@ -11,7 +11,7 @@ import type { Collection, CustomCollectionBackend, Tool, WorkflowToolProviderReq | |||
| import ToolItem from './tool-item' | |||
| import cn from '@/utils/classnames' | |||
| import I18n from '@/context/i18n' | |||
| import { getLanguage } from '@/i18n/language' | |||
| import { getLanguage } from '@/i18n-config/language' | |||
| import Confirm from '@/app/components/base/confirm' | |||
| import Button from '@/app/components/base/button' | |||
| import Indicator from '@/app/components/header/indicator' | |||
| @@ -4,7 +4,7 @@ import { useContext } from 'use-context-selector' | |||
| import type { Collection, Tool } from '../types' | |||
| import cn from '@/utils/classnames' | |||
| 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' | |||
| type Props = { | |||
| @@ -3,7 +3,7 @@ import { ALL_CHAT_AVAILABLE_BLOCKS, ALL_COMPLETION_AVAILABLE_BLOCKS } from '@/ap | |||
| import type { NodeDefault } from '../../types' | |||
| import type { AgentNodeType } from './types' | |||
| 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> = { | |||
| defaultValue: { | |||
| @@ -13,7 +13,7 @@ import { fetchSupportFileTypes } from '@/service/datasets' | |||
| import Field from '@/app/components/workflow/nodes/_base/components/field' | |||
| import { BlockEnum, type NodePanelProps } from '@/app/components/workflow/types' | |||
| import I18n from '@/context/i18n' | |||
| import { LanguagesSupported } from '@/i18n/language' | |||
| import { LanguagesSupported } from '@/i18n-config/language' | |||
| const i18nPrefix = 'workflow.nodes.docExtractor' | |||
| @@ -1,8 +1,8 @@ | |||
| 'use client' | |||
| import { loadLangResources } from '@/i18n/i18next-config' | |||
| import { loadLangResources } from '@/i18n-config/i18next-config' | |||
| import { useCallback, useEffect, useState } from 'react' | |||
| import cn from '@/utils/classnames' | |||
| import { LanguagesSupported } from '@/i18n/language' | |||
| import { LanguagesSupported } from '@/i18n-config/language' | |||
| export default function I18nTest() { | |||
| const [langs, setLangs] = useState<Lang[]>([]) | |||
| @@ -3,7 +3,7 @@ import type { Viewport } from 'next' | |||
| import I18nServer from './components/i18n-server' | |||
| import BrowserInitializer from './components/browser-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 { ThemeProvider } from 'next-themes' | |||
| import './styles/globals.css' | |||
| @@ -3,8 +3,8 @@ import React from 'react' | |||
| import { useContext } from 'use-context-selector' | |||
| import Select from '@/app/components/base/select/locale' | |||
| 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 dynamic from 'next/dynamic' | |||
| import { useGlobalPublicStore } from '@/context/global-public-context' | |||
| @@ -11,7 +11,7 @@ import Input from '@/app/components/base/input' | |||
| import { SimpleSelect } from '@/app/components/base/select' | |||
| import Button from '@/app/components/base/button' | |||
| import { timezones } from '@/utils/timezone' | |||
| import { LanguagesSupported, languages } from '@/i18n/language' | |||
| import { LanguagesSupported, languages } from '@/i18n-config/language' | |||
| import I18n from '@/context/i18n' | |||
| import { activateMember, invitationCheck } from '@/service/common' | |||
| import Loading from '@/app/components/base/loading' | |||
| @@ -9,7 +9,7 @@ import Button from '@/app/components/base/button' | |||
| import Tooltip from '@/app/components/base/tooltip' | |||
| import { SimpleSelect } from '@/app/components/base/select' | |||
| import { timezones } from '@/utils/timezone' | |||
| import { LanguagesSupported, languages } from '@/i18n/language' | |||
| import { LanguagesSupported, languages } from '@/i18n-config/language' | |||
| import { oneMoreStep } from '@/service/common' | |||
| import Toast from '@/app/components/base/toast' | |||
| import { useDocLink } from '@/context/i18n' | |||
| @@ -2,8 +2,8 @@ import { | |||
| createContext, | |||
| useContext, | |||
| } 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' | |||
| type II18NContext = { | |||
| @@ -1,5 +1,5 @@ | |||
| import { useLanguage } from '@/app/components/header/account-setting/model-provider-page/hooks' | |||
| import { renderI18nObject } from '@/i18n' | |||
| import { renderI18nObject } from '@/i18n-config' | |||
| export const useRenderI18nObject = () => { | |||
| const language = useLanguage() | |||
| @@ -1,4 +1,3 @@ | |||
| /* eslint-disable no-eval */ | |||
| const fs = require('node:fs') | |||
| const path = require('node:path') | |||
| const transpile = require('typescript').transpile | |||
| @@ -1,4 +1,3 @@ | |||
| /* eslint-disable no-eval */ | |||
| const fs = require('node:fs') | |||
| const path = require('node:path') | |||
| const transpile = require('typescript').transpile | |||
| @@ -6,10 +6,10 @@ import { initReactI18next } from 'react-i18next' | |||
| const requireSilent = async (lang: string, namespace: string) => { | |||
| let res | |||
| try { | |||
| res = (await import(`./${lang}/${namespace}`)).default | |||
| res = (await import(`../i18n/${lang}/${namespace}`)).default | |||
| } | |||
| catch { | |||
| res = (await import(`./en-US/${namespace}`)).default | |||
| res = (await import(`../i18n/en-US/${namespace}`)).default | |||
| } | |||
| return res | |||
| @@ -53,13 +53,27 @@ export const loadLangResources = async (lang: string) => { | |||
| 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 | |||
| }, {} as Record<string, any>) | |||
| return { | |||
| translation: resources, | |||
| 'en-US': { | |||
| translation: en_USResources, | |||
| }, | |||
| 'zh-Hans': { | |||
| translation: zh_HansResources, | |||
| }, | |||
| } | |||
| } | |||
| @@ -68,9 +82,7 @@ if (!i18n.isInitialized) { | |||
| .init({ | |||
| lng: undefined, | |||
| fallbackLng: 'en-US', | |||
| resources: { | |||
| 'en-US': getFallbackTranslation(), | |||
| }, | |||
| resources: getInitialTranslations(), | |||
| }) | |||
| } | |||
| @@ -1,8 +1,8 @@ | |||
| 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 { LanguagesSupported } from '@/i18n/language' | |||
| import { LanguagesSupported } from '@/i18n-config/language' | |||
| export const i18n = { | |||
| defaultLocale: 'en-US', | |||
| @@ -13,7 +13,7 @@ const initI18next = async (lng: Locale, ns: string) => { | |||
| const i18nInstance = createInstance() | |||
| await i18nInstance | |||
| .use(initReactI18next) | |||
| .use(resourcesToBackend((language: string, namespace: string) => import(`./${language}/${namespace}.ts`))) | |||
| .use(resourcesToBackend((language: string, namespace: string) => import(`../i18n/${language}/${namespace}.ts`))) | |||
| .init({ | |||
| lng: lng === 'zh-Hans' ? 'zh-Hans' : lng, | |||
| ns, | |||
| @@ -1,4 +1,4 @@ | |||
| import type { I18nText } from '@/i18n/language' | |||
| import type { I18nText } from '@/i18n-config/language' | |||
| import type { Model } from '@/types/app' | |||
| export type CommonResponse = { | |||
| @@ -1,4 +1,4 @@ | |||
| import type { Locale } from '@/i18n' | |||
| import type { Locale } from '@/i18n-config' | |||
| import type { AppIconType } from '@/types/app' | |||
| export type ResponseHolder = {} | |||
| @@ -1,6 +1,6 @@ | |||
| import type { AnnotationReplyConfig, ChatPromptConfig, CompletionPromptConfig, DatasetConfigs, PromptMode } from '@/models/debug' | |||
| 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 { | |||
| RerankingModeEnum, | |||