fix: marketplace i18n

This commit is contained in:
zxhlyh 2024-12-27 11:54:20 +08:00
parent 697ee496b7
commit 5cdca9cafe
7 changed files with 21 additions and 14 deletions

View File

@ -1,21 +1,23 @@
'use client' 'use client'
import { useTranslation } from 'react-i18next'
import { Group } from '@/app/components/base/icons/src/vender/other' import { Group } from '@/app/components/base/icons/src/vender/other'
import Line from './line' import Line from './line'
import cn from '@/utils/classnames' import cn from '@/utils/classnames'
import { useMixedTranslation } from '@/app/components/plugins/marketplace/hooks'
type Props = { type Props = {
text?: string text?: string
lightCard?: boolean lightCard?: boolean
className?: string className?: string
locale?: string
} }
const Empty = ({ const Empty = ({
text, text,
lightCard, lightCard,
className, className,
locale,
}: Props) => { }: Props) => {
const { t } = useTranslation() const { t } = useMixedTranslation(locale)
return ( return (
<div <div

View File

@ -69,7 +69,7 @@ const List = ({
} }
{ {
plugins && !plugins.length && ( plugins && !plugins.length && (
<Empty className={emptyClassName} /> <Empty className={emptyClassName} locale={locale} />
) )
} }
</> </>

View File

@ -1,6 +1,5 @@
'use client' 'use client'
import { useTranslation } from 'react-i18next'
import { RiArrowRightSLine } from '@remixicon/react' import { RiArrowRightSLine } from '@remixicon/react'
import type { MarketplaceCollection } from '../types' import type { MarketplaceCollection } from '../types'
import CardWrapper from './card-wrapper' import CardWrapper from './card-wrapper'
@ -8,6 +7,7 @@ import type { Plugin } from '@/app/components/plugins/types'
import { getLanguage } from '@/i18n/language' import { getLanguage } from '@/i18n/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'
type ListWithCollectionProps = { type ListWithCollectionProps = {
marketplaceCollections: MarketplaceCollection[] marketplaceCollections: MarketplaceCollection[]
@ -27,7 +27,7 @@ const ListWithCollection = ({
cardRender, cardRender,
onMoreClick, onMoreClick,
}: ListWithCollectionProps) => { }: ListWithCollectionProps) => {
const { t } = useTranslation() const { t } = useMixedTranslation(locale)
return ( return (
<> <>

View File

@ -1,12 +1,12 @@
'use client' 'use client'
import { useEffect } from 'react' import { useEffect } from 'react'
import { useTranslation } from 'react-i18next'
import type { Plugin } from '../../types' import type { Plugin } from '../../types'
import type { MarketplaceCollection } from '../types' import type { MarketplaceCollection } from '../types'
import { useMarketplaceContext } from '../context' import { useMarketplaceContext } from '../context'
import List from './index' import List from './index'
import SortDropdown from '../sort-dropdown' import SortDropdown from '../sort-dropdown'
import Loading from '@/app/components/base/loading' import Loading from '@/app/components/base/loading'
import { useMixedTranslation } from '@/app/components/plugins/marketplace/hooks'
type ListWrapperProps = { type ListWrapperProps = {
marketplaceCollections: MarketplaceCollection[] marketplaceCollections: MarketplaceCollection[]
@ -20,7 +20,7 @@ const ListWrapper = ({
showInstallButton, showInstallButton,
locale, locale,
}: ListWrapperProps) => { }: ListWrapperProps) => {
const { t } = useTranslation() const { t } = useMixedTranslation(locale)
const plugins = useMarketplaceContext(v => v.plugins) const plugins = useMarketplaceContext(v => v.plugins)
const pluginsTotal = useMarketplaceContext(v => v.pluginsTotal) const pluginsTotal = useMarketplaceContext(v => v.pluginsTotal)
const marketplaceCollectionsFromClient = useMarketplaceContext(v => v.marketplaceCollectionsFromClient) const marketplaceCollectionsFromClient = useMarketplaceContext(v => v.marketplaceCollectionsFromClient)
@ -43,7 +43,7 @@ const ListWrapper = ({
<div className='top-5 flex items-center mb-4 pt-3'> <div className='top-5 flex items-center mb-4 pt-3'>
<div className='title-xl-semi-bold text-text-primary'>{t('plugin.marketplace.pluginsResult', { num: pluginsTotal })}</div> <div className='title-xl-semi-bold text-text-primary'>{t('plugin.marketplace.pluginsResult', { num: pluginsTotal })}</div>
<div className='mx-3 w-[1px] h-3.5 bg-divider-regular'></div> <div className='mx-3 w-[1px] h-3.5 bg-divider-regular'></div>
<SortDropdown /> <SortDropdown locale={locale} />
</div> </div>
) )
} }

View File

@ -4,7 +4,7 @@ import {
RiBrain2Line, RiBrain2Line,
RiHammerLine, RiHammerLine,
RiPuzzle2Line, RiPuzzle2Line,
RiUmbrellaLine, RiSpeakAiLine,
} from '@remixicon/react' } from '@remixicon/react'
import { PluginType } from '../types' import { PluginType } from '../types'
import { useMarketplaceContext } from './context' import { useMarketplaceContext } from './context'
@ -50,7 +50,7 @@ const PluginTypeSwitch = ({
{ {
value: PLUGIN_TYPE_SEARCH_MAP.agent, value: PLUGIN_TYPE_SEARCH_MAP.agent,
text: t('plugin.category.agents'), text: t('plugin.category.agents'),
icon: <RiUmbrellaLine className='mr-1.5 w-4 h-4' />, icon: <RiSpeakAiLine className='mr-1.5 w-4 h-4' />,
}, },
{ {
value: PLUGIN_TYPE_SEARCH_MAP.extension, value: PLUGIN_TYPE_SEARCH_MAP.extension,

View File

@ -4,16 +4,21 @@ import {
RiArrowDownSLine, RiArrowDownSLine,
RiCheckLine, RiCheckLine,
} from '@remixicon/react' } from '@remixicon/react'
import { useTranslation } from 'react-i18next'
import { useMarketplaceContext } from '../context' import { useMarketplaceContext } from '../context'
import { import {
PortalToFollowElem, PortalToFollowElem,
PortalToFollowElemContent, PortalToFollowElemContent,
PortalToFollowElemTrigger, PortalToFollowElemTrigger,
} from '@/app/components/base/portal-to-follow-elem' } from '@/app/components/base/portal-to-follow-elem'
import { useMixedTranslation } from '@/app/components/plugins/marketplace/hooks'
const SortDropdown = () => { type SortDropdownProps = {
const { t } = useTranslation() locale?: string
}
const SortDropdown = ({
locale,
}: SortDropdownProps) => {
const { t } = useMixedTranslation(locale)
const options = [ const options = [
{ {
value: 'install_count', value: 'install_count',

View File

@ -3,7 +3,7 @@ const translation = {
all: '全部', all: '全部',
models: '模型', models: '模型',
tools: '工具', tools: '工具',
agents: 'Agent Strategy', agents: 'Agent 策略',
extensions: '扩展', extensions: '扩展',
bundles: '插件集', bundles: '插件集',
}, },