diff --git a/web/app/components/plugins/install-plugin/install-from-local-package/index.tsx b/web/app/components/plugins/install-plugin/install-from-local-package/index.tsx index f3e618ad08..ab378f3d2d 100644 --- a/web/app/components/plugins/install-plugin/install-from-local-package/index.tsx +++ b/web/app/components/plugins/install-plugin/install-from-local-package/index.tsx @@ -1,14 +1,15 @@ 'use client' import React, { useCallback, useState } from 'react' -import { useContext } from 'use-context-selector' import Modal from '@/app/components/base/modal' -import I18n from '@/context/i18n' import type { PluginDeclaration } from '../../types' import { InstallStep } from '../../types' import Uploading from './steps/uploading' import Install from './steps/install' import Installed from './steps/installed' +import { useTranslation } from 'react-i18next' + +const i18nPrefix = 'plugin.installModal' type InstallFromLocalPackageProps = { file: File @@ -18,12 +19,18 @@ type InstallFromLocalPackageProps = { const InstallFromLocalPackage: React.FC = ({ file, - onClose + onClose, }) => { + const { t } = useTranslation() const [step, setStep] = useState(InstallStep.uploading) - const { locale } = useContext(I18n) const [uniqueIdentifier, setUniqueIdentifier] = useState(null) + + const getTitle = useCallback(() => { + if (step === InstallStep.installed) + return t(`${i18nPrefix}.installedSuccessfully`) + return t(`${i18nPrefix}.installPlugin`) + }, []) const [manifest, setManifest] = useState({ name: 'Notion Sync', description: 'Sync your Notion notes with Dify', @@ -51,7 +58,7 @@ const InstallFromLocalPackage: React.FC = ({ >
- Install plugin + {getTitle()}
{step === InstallStep.uploading && ( diff --git a/web/app/components/plugins/install-plugin/install-from-local-package/steps/install.tsx b/web/app/components/plugins/install-plugin/install-from-local-package/steps/install.tsx index 6ccfd8a88a..a20da68447 100644 --- a/web/app/components/plugins/install-plugin/install-from-local-package/steps/install.tsx +++ b/web/app/components/plugins/install-plugin/install-from-local-package/steps/install.tsx @@ -6,6 +6,9 @@ import Card from '../../../card' import { pluginManifestToCardPluginProps } from '../../utils' import Button from '@/app/components/base/button' import { sleep } from '@/utils' +import { Trans, useTranslation } from 'react-i18next' + +const i18nPrefix = 'plugin.installModal' type Props = { payload: PluginDeclaration @@ -18,6 +21,7 @@ const Installed: FC = ({ onCancel, onInstalled, }) => { + const { t } = useTranslation() const [isInstalling, setIsInstalling] = React.useState(false) const handleInstall = async () => { @@ -31,8 +35,13 @@ const Installed: FC = ({ <>
-

About to install the following plugin.

-

Please make sure that you only install plugins from a trusted source.

+

{t(`${i18nPrefix}.readyToInstall`)}

+

+ }} + /> +

= ({
{!isInstalling && ( )}
diff --git a/web/app/components/plugins/install-plugin/install-from-local-package/steps/installed.tsx b/web/app/components/plugins/install-plugin/install-from-local-package/steps/installed.tsx index fa07359ecc..34fad51691 100644 --- a/web/app/components/plugins/install-plugin/install-from-local-package/steps/installed.tsx +++ b/web/app/components/plugins/install-plugin/install-from-local-package/steps/installed.tsx @@ -5,6 +5,7 @@ import type { PluginDeclaration } from '../../../types' import Card from '../../../card' import Button from '@/app/components/base/button' import { pluginManifestToCardPluginProps } from '../../utils' +import { useTranslation } from 'react-i18next' type Props = { payload: PluginDeclaration @@ -14,8 +15,9 @@ type Props = { const Installed: FC = ({ payload, - onCancel + onCancel, }) => { + const { t } = useTranslation() return ( <>
@@ -35,7 +37,7 @@ const Installed: FC = ({ className='min-w-[72px]' onClick={onCancel} > - close + {t('common.operation.close')}
diff --git a/web/app/components/plugins/install-plugin/install-from-local-package/steps/uploading.tsx b/web/app/components/plugins/install-plugin/install-from-local-package/steps/uploading.tsx index 5f2ce5ce74..043897f068 100644 --- a/web/app/components/plugins/install-plugin/install-from-local-package/steps/uploading.tsx +++ b/web/app/components/plugins/install-plugin/install-from-local-package/steps/uploading.tsx @@ -6,6 +6,9 @@ import Card from '../../../card' import type { PluginDeclaration } from '../../../types' import Button from '@/app/components/base/button' import { sleep } from '@/utils' +import { useTranslation } from 'react-i18next' + +const i18nPrefix = 'plugin.installModal' type Props = { file: File @@ -21,9 +24,10 @@ const Uploading: FC = ({ onCancel, onUploaded, }) => { + const { t } = useTranslation() const fileName = file.name const handleUpload = async () => { - await sleep(1500) + await sleep(3000) onUploaded({ uniqueIdentifier: 'yeuoly/neko:0.0.1@5395654da2c0b919b3d9b946a1a0545b737004380765e5f3b8c49976d3276c87', manifest: { @@ -42,7 +46,9 @@ const Uploading: FC = ({
- Uploading {fileName}... + {t(`${i18nPrefix}.uploadingPackage`, { + packageName: fileName, + })}
@@ -59,14 +65,14 @@ const Uploading: FC = ({ {/* Action Buttons */}
diff --git a/web/i18n/en-US/common.ts b/web/i18n/en-US/common.ts index 29d5581f35..654d9ec404 100644 --- a/web/i18n/en-US/common.ts +++ b/web/i18n/en-US/common.ts @@ -39,6 +39,7 @@ const translation = { duplicate: 'Duplicate', rename: 'Rename', audioSourceUnavailable: 'AudioSource is unavailable', + close: 'Close', }, errorMsg: { fieldRequired: '{{field}} is required', diff --git a/web/i18n/en-US/plugin.ts b/web/i18n/en-US/plugin.ts index b2ce5654ad..6f6579d9d4 100644 --- a/web/i18n/en-US/plugin.ts +++ b/web/i18n/en-US/plugin.ts @@ -59,6 +59,15 @@ const translation = { deleteContentRight: ' plugin?', usedInApps: 'This plugin is being used in {{num}} apps.', }, + installModal: { + installPlugin: 'Install Plugin', + installedSuccessfully: 'Install successful', + install: 'Install', + installing: 'Installing...', + uploadingPackage: 'Uploading {{packageName}}...', + readyToInstall: 'About to install the following plugin.', + fromTrustSource: 'Please make sure that you only install plugins from a trusted source.', + }, upgrade: { title: 'Upgrade Plugin', successfulTitle: 'Upgrade successful', diff --git a/web/i18n/zh-Hans/common.ts b/web/i18n/zh-Hans/common.ts index e683708e04..a783bf8424 100644 --- a/web/i18n/zh-Hans/common.ts +++ b/web/i18n/zh-Hans/common.ts @@ -39,6 +39,7 @@ const translation = { duplicate: '复制', rename: '重命名', audioSourceUnavailable: '音源不可用', + close: '关闭', }, errorMsg: { fieldRequired: '{{field}} 为必填项', diff --git a/web/i18n/zh-Hans/plugin.ts b/web/i18n/zh-Hans/plugin.ts index 69f0aeb079..35e522fd84 100644 --- a/web/i18n/zh-Hans/plugin.ts +++ b/web/i18n/zh-Hans/plugin.ts @@ -59,6 +59,15 @@ const translation = { deleteContentRight: ' 插件?', usedInApps: '此插件正在 {{num}} 个应用中使用。', }, + installModal: { + installPlugin: '安装插件', + installedSuccessfully: '安装成功', + install: '安装', + installing: '安装中...', + uploadingPackage: '上传 {{packageName}} 中...', + readyToInstall: '即将安装以下插件。', + fromTrustSource: '请保证仅从可信源安装插件。', + }, upgrade: { title: '升级插件', successfulTitle: '升级成功',