From cd2860deb4048db0224a4d912d642a3a6462911d Mon Sep 17 00:00:00 2001 From: twwu Date: Thu, 14 Nov 2024 15:47:22 +0800 Subject: [PATCH] feat: add i18n support for plugin installation and empty states --- .../plugins/plugin-page/empty/index.tsx | 14 ++++++++------ .../plugin-page/install-plugin-dropdown.tsx | 12 +++++++----- web/i18n/en-US/plugin.ts | 16 ++++++++++++++++ web/i18n/zh-Hans/plugin.ts | 16 ++++++++++++++++ 4 files changed, 47 insertions(+), 11 deletions(-) diff --git a/web/app/components/plugins/plugin-page/empty/index.tsx b/web/app/components/plugins/plugin-page/empty/index.tsx index 3092e0f444..06dc41492f 100644 --- a/web/app/components/plugins/plugin-page/empty/index.tsx +++ b/web/app/components/plugins/plugin-page/empty/index.tsx @@ -9,8 +9,10 @@ import { Group } from '@/app/components/base/icons/src/vender/other' import { useSelector as useAppContextSelector } from '@/context/app-context' import Line from '../../marketplace/empty/line' import { useInstalledPluginList, useInvalidateInstalledPluginList } from '@/service/use-plugins' +import { useTranslation } from 'react-i18next' const Empty = () => { + const { t } = useTranslation() const fileInputRef = useRef(null) const [selectedAction, setSelectedAction] = useState(null) const [selectedFile, setSelectedFile] = useState(null) @@ -30,9 +32,9 @@ const Empty = () => { const text = useMemo(() => { if (pluginList?.plugins.length === 0) - return 'No plugins installed' + return t('plugin.list.noInstalled') if (filters.categories.length > 0 || filters.tags.length > 0 || filters.searchQuery) - return 'No plugins found' + return t('plugin.list.notFound') }, [pluginList, filters]) return ( @@ -70,11 +72,11 @@ const Empty = () => { {[ ...( (enable_marketplace || true) - ? [{ icon: MagicBox, text: 'Marketplace', action: 'marketplace' }] + ? [{ icon: MagicBox, text: t('plugin.list.source.marketplace'), action: 'marketplace' }] : [] ), - { icon: Github, text: 'GitHub', action: 'github' }, - { icon: FileZip, text: 'Local Package File', action: 'local' }, + { icon: Github, text: t('plugin.list.source.github'), action: 'github' }, + { icon: FileZip, text: t('plugin.list.source.local'), action: 'local' }, ].map(({ icon: Icon, text, action }) => (
{ }} > - {`Install from ${text}`} + {text}
))} diff --git a/web/app/components/plugins/plugin-page/install-plugin-dropdown.tsx b/web/app/components/plugins/plugin-page/install-plugin-dropdown.tsx index 3d1351b67c..826aba334b 100644 --- a/web/app/components/plugins/plugin-page/install-plugin-dropdown.tsx +++ b/web/app/components/plugins/plugin-page/install-plugin-dropdown.tsx @@ -16,6 +16,7 @@ import { } from '@/app/components/base/portal-to-follow-elem' import { useSelector as useAppContextSelector } from '@/context/app-context' import { useInvalidateInstalledPluginList } from '@/service/use-plugins' +import { useTranslation } from 'react-i18next' type Props = { onSwitchToMarketplaceTab: () => void @@ -23,6 +24,7 @@ type Props = { const InstallPluginDropdown = ({ onSwitchToMarketplaceTab, }: Props) => { + const { t } = useTranslation() const fileInputRef = useRef(null) const [isMenuOpen, setIsMenuOpen] = useState(false) const [selectedAction, setSelectedAction] = useState(null) @@ -65,14 +67,14 @@ const InstallPluginDropdown = ({ className={cn('w-full h-full p-2 text-components-button-secondary-text', isMenuOpen && 'bg-state-base-hover')} > - Install plugin + {t('plugin.installPlugin')}
- Install From + {t('plugin.installFrom')} (