diff --git a/web/app/components/plugins/install-plugin/install-from-github/index.tsx b/web/app/components/plugins/install-plugin/install-from-github/index.tsx index 731c7db7ac..06c4c0797a 100644 --- a/web/app/components/plugins/install-plugin/install-from-github/index.tsx +++ b/web/app/components/plugins/install-plugin/install-from-github/index.tsx @@ -3,33 +3,21 @@ import React, { useState } from 'react' import Modal from '@/app/components/base/modal' import type { Item } from '@/app/components/base/select' -import type { GitHubRepoReleaseResponse } from '@/app/components/plugins/types' +import type { GitHubUrlInfo, InstallState } from '@/app/components/plugins/types' import { InstallStepFromGitHub } from '../../types' import Toast from '@/app/components/base/toast' import SetURL from './steps/setURL' import SetVersion from './steps/setVersion' import SetPackage from './steps/setPackage' import Installed from './steps/installed' +import { useTranslation } from 'react-i18next' type InstallFromGitHubProps = { onClose: () => void } -type GitHubUrlInfo = { - isValid: boolean - owner?: string - repo?: string -} - -type InstallState = { - step: InstallStepFromGitHub - repoUrl: string - selectedVersion: string - selectedPackage: string - releases: GitHubRepoReleaseResponse[] -} - const InstallFromGitHub: React.FC = ({ onClose }) => { + const { t } = useTranslation() const [state, setState] = useState({ step: InstallStepFromGitHub.setUrl, repoUrl: '', @@ -92,7 +80,7 @@ const InstallFromGitHub: React.FC = ({ onClose }) => { if (!isValid || !owner || !repo) { Toast.notify({ type: 'error', - message: 'Invalid GitHub URL. Please enter a valid URL in the format: https://github.com/owner/repo', + message: t('plugin.error.inValidGitHubUrl'), }) break } @@ -151,10 +139,10 @@ const InstallFromGitHub: React.FC = ({ onClose }) => {
- Install plugin from GitHub + {t('plugin.installFromGitHub.installPlugin')}
- {state.step !== InstallStepFromGitHub.installed && 'Please make sure that you only install plugins from a trusted source.'} + {state.step !== InstallStepFromGitHub.installed && t('plugin.installFromGitHub.installNote')}
diff --git a/web/app/components/plugins/install-plugin/install-from-github/steps/installed.tsx b/web/app/components/plugins/install-plugin/install-from-github/steps/installed.tsx index be6dc5b312..97be133451 100644 --- a/web/app/components/plugins/install-plugin/install-from-github/steps/installed.tsx +++ b/web/app/components/plugins/install-plugin/install-from-github/steps/installed.tsx @@ -1,5 +1,6 @@ import React from 'react' import Button from '@/app/components/base/button' +import { useTranslation } from 'react-i18next' type InstalledProps = { repoUrl: string @@ -23,28 +24,31 @@ const InfoRow = ({ label, value }: { label: string; value: string }) => ( ) -const Installed: React.FC = ({ repoUrl, selectedVersion, selectedPackage, onClose }) => ( - <> -
The plugin has been installed successfully.
-
- {[ - { label: 'Repository', value: repoUrl }, - { label: 'Version', value: selectedVersion }, - { label: 'Package', value: selectedPackage }, - ].map(({ label, value }) => ( - - ))} -
-
- -
- -) +const Installed: React.FC = ({ repoUrl, selectedVersion, selectedPackage, onClose }) => { + const { t } = useTranslation() + return ( + <> +
The plugin has been installed successfully.
+
+ {[ + { label: t('plugin.installModal.labels.repository'), value: repoUrl }, + { label: t('plugin.installModal.labels.version'), value: selectedVersion }, + { label: t('plugin.installModal.labels.package'), value: selectedPackage }, + ].map(({ label, value }) => ( + + ))} +
+
+ +
+ + ) +} export default Installed diff --git a/web/app/components/plugins/install-plugin/install-from-github/steps/setPackage.tsx b/web/app/components/plugins/install-plugin/install-from-github/steps/setPackage.tsx index 2abadb8eb8..2db55aa56f 100644 --- a/web/app/components/plugins/install-plugin/install-from-github/steps/setPackage.tsx +++ b/web/app/components/plugins/install-plugin/install-from-github/steps/setPackage.tsx @@ -2,6 +2,7 @@ import React from 'react' import type { Item } from '@/app/components/base/select' import { PortalSelect } from '@/app/components/base/select' import Button from '@/app/components/base/button' +import { useTranslation } from 'react-i18next' type SetPackageProps = { selectedPackage: string @@ -11,39 +12,42 @@ type SetPackageProps = { onBack: () => void } -const SetPackage: React.FC = ({ selectedPackage, packages, onSelect, onInstall, onBack }) => ( - <> - - -
- - -
- -) + {t('plugin.installFromGitHub.selectPackage')} + + +
+ + +
+ + ) +} export default SetPackage diff --git a/web/app/components/plugins/install-plugin/install-from-github/steps/setURL.tsx b/web/app/components/plugins/install-plugin/install-from-github/steps/setURL.tsx index a4bfd9f3f3..9ec6cd6eee 100644 --- a/web/app/components/plugins/install-plugin/install-from-github/steps/setURL.tsx +++ b/web/app/components/plugins/install-plugin/install-from-github/steps/setURL.tsx @@ -1,5 +1,6 @@ import React from 'react' import Button from '@/app/components/base/button' +import { useTranslation } from 'react-i18next' type SetURLProps = { repoUrl: string @@ -8,43 +9,46 @@ type SetURLProps = { onCancel: () => void } -const SetURL: React.FC = ({ repoUrl, onChange, onNext, onCancel }) => ( - <> - - onChange(e.target.value)} - className='flex items-center self-stretch rounded-lg border border-components-input-border-active - bg-components-input-bg-active shadows-shadow-xs p-2 gap-[2px] flex-grow overflow-hidden - text-components-input-text-filled text-ellipsis system-sm-regular' - placeholder='Please enter GitHub repo URL' - /> -
- - -
- -) + {t('plugin.installFromGitHub.gitHubRepo')} + + onChange(e.target.value)} + className='flex items-center self-stretch rounded-lg border border-components-input-border-active + bg-components-input-bg-active shadows-shadow-xs p-2 gap-[2px] flex-grow overflow-hidden + text-components-input-text-filled text-ellipsis system-sm-regular' + placeholder='Please enter GitHub repo URL' + /> +
+ + +
+ + ) +} export default SetURL diff --git a/web/app/components/plugins/install-plugin/install-from-github/steps/setVersion.tsx b/web/app/components/plugins/install-plugin/install-from-github/steps/setVersion.tsx index a3f72f0f29..042ab2b093 100644 --- a/web/app/components/plugins/install-plugin/install-from-github/steps/setVersion.tsx +++ b/web/app/components/plugins/install-plugin/install-from-github/steps/setVersion.tsx @@ -2,6 +2,7 @@ import React from 'react' import type { Item } from '@/app/components/base/select' import { PortalSelect } from '@/app/components/base/select' import Button from '@/app/components/base/button' +import { useTranslation } from 'react-i18next' type SetVersionProps = { selectedVersion: string @@ -11,39 +12,42 @@ type SetVersionProps = { onBack: () => void } -const SetVersion: React.FC = ({ selectedVersion, versions, onSelect, onNext, onBack }) => ( - <> - - -
- - -
- -) + {t('plugin.installFromGitHub.selectVersion')} + + +
+ + +
+ + ) +} export default SetVersion diff --git a/web/app/components/plugins/plugin-page/filter-management/search-box.tsx b/web/app/components/plugins/plugin-page/filter-management/search-box.tsx index fa158aadf0..1b67a9a112 100644 --- a/web/app/components/plugins/plugin-page/filter-management/search-box.tsx +++ b/web/app/components/plugins/plugin-page/filter-management/search-box.tsx @@ -12,7 +12,8 @@ const SearchBox: React.FC = ({ }) => { return ( trusted source.', + labels: { + repository: 'Repository', + version: 'Version', + package: 'Package', + }, + close: 'Close', + cancel: 'Cancel', + back: 'Back', + next: 'Next', + }, + installFromGitHub: { + installPlugin: 'Install plugin from GitHub', + gitHubRepo: 'GitHub repository', + selectVersion: 'Select version', + selectVersionPlaceholder: 'Please select a version', + installNote: 'Please make sure that you only install plugins from a trusted source.', + selectPackage: 'Select package', + selectPackagePlaceholder: 'Please select a package', }, upgrade: { title: 'Upgrade Plugin', @@ -77,6 +95,9 @@ const translation = { upgrading: 'Upgrading...', close: 'Close', }, + error: { + inValidGitHubUrl: 'Invalid GitHub URL. Please enter a valid URL in the format: https://github.com/owner/repo', + }, } export default translation diff --git a/web/i18n/zh-Hans/plugin.ts b/web/i18n/zh-Hans/plugin.ts index 35e522fd84..2d5a39b7df 100644 --- a/web/i18n/zh-Hans/plugin.ts +++ b/web/i18n/zh-Hans/plugin.ts @@ -67,6 +67,24 @@ const translation = { uploadingPackage: '上传 {{packageName}} 中...', readyToInstall: '即将安装以下插件。', fromTrustSource: '请保证仅从可信源安装插件。', + labels: { + repository: '仓库', + version: '版本', + package: '包', + }, + close: '关闭', + cancel: '取消', + back: '返回', + next: '下一步', + }, + installFromGitHub: { + installPlugin: '从 GitHub 安装插件', + gitHubRepo: 'GitHub 仓库', + selectVersion: '选择版本', + selectVersionPlaceholder: '请选择一个版本', + installNote: '请确保只从可信源安装插件。', + selectPackage: '选择包', + selectPackagePlaceholder: '请选择一个包', }, upgrade: { title: '升级插件', @@ -77,6 +95,9 @@ const translation = { upgrading: '升级中...', close: '关闭', }, + error: { + inValidGitHubUrl: '无效的 GitHub URL。请输入格式为 https://github.com/owner/repo 的有效 URL', + }, } export default translation