feat: enhance plugin item localization with i18n support
This commit is contained in:
parent
055fb22b9b
commit
c458c28c62
@ -20,11 +20,11 @@ import Title from '../card/base/title'
|
|||||||
import Action from './action'
|
import Action from './action'
|
||||||
import cn from '@/utils/classnames'
|
import cn from '@/utils/classnames'
|
||||||
import { API_PREFIX, MARKETPLACE_URL_PREFIX } from '@/config'
|
import { API_PREFIX, MARKETPLACE_URL_PREFIX } from '@/config'
|
||||||
import { useLanguage } from '../../header/account-setting/model-provider-page/hooks'
|
|
||||||
import { useInvalidateInstalledPluginList } from '@/service/use-plugins'
|
import { useInvalidateInstalledPluginList } from '@/service/use-plugins'
|
||||||
import { useInvalidateAllToolProviders } from '@/service/use-tools'
|
import { useInvalidateAllToolProviders } from '@/service/use-tools'
|
||||||
import { useCategories } from '../hooks'
|
import { useCategories } from '../hooks'
|
||||||
import { useProviderContext } from '@/context/provider-context'
|
import { useProviderContext } from '@/context/provider-context'
|
||||||
|
import { useRenderI18nObject } from '@/hooks/use-i18n'
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
className?: string
|
className?: string
|
||||||
@ -35,7 +35,6 @@ const PluginItem: FC<Props> = ({
|
|||||||
className,
|
className,
|
||||||
plugin,
|
plugin,
|
||||||
}) => {
|
}) => {
|
||||||
const locale = useLanguage()
|
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const { categoriesMap } = useCategories()
|
const { categoriesMap } = useCategories()
|
||||||
const currentPluginID = usePluginPageContext(v => v.currentPluginID)
|
const currentPluginID = usePluginPageContext(v => v.currentPluginID)
|
||||||
@ -66,6 +65,10 @@ const PluginItem: FC<Props> = ({
|
|||||||
if (PluginType.tool.includes(category))
|
if (PluginType.tool.includes(category))
|
||||||
invalidateAllToolProviders()
|
invalidateAllToolProviders()
|
||||||
}
|
}
|
||||||
|
const renderI18nObject = useRenderI18nObject()
|
||||||
|
const title = renderI18nObject(label)
|
||||||
|
const descriptionText = renderI18nObject(description)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={cn(
|
className={cn(
|
||||||
@ -92,12 +95,12 @@ const PluginItem: FC<Props> = ({
|
|||||||
</div>
|
</div>
|
||||||
<div className="ml-3 w-0 grow">
|
<div className="ml-3 w-0 grow">
|
||||||
<div className="flex items-center h-5">
|
<div className="flex items-center h-5">
|
||||||
<Title title={label[locale]} />
|
<Title title={title} />
|
||||||
{verified && <RiVerifiedBadgeLine className="shrink-0 ml-0.5 w-4 h-4 text-text-accent" />}
|
{verified && <RiVerifiedBadgeLine className="shrink-0 ml-0.5 w-4 h-4 text-text-accent" />}
|
||||||
<Badge className='shrink-0 ml-1' text={source === PluginSource.github ? plugin.meta!.version : plugin.version} />
|
<Badge className='shrink-0 ml-1' text={source === PluginSource.github ? plugin.meta!.version : plugin.version} />
|
||||||
</div>
|
</div>
|
||||||
<div className='flex items-center justify-between'>
|
<div className='flex items-center justify-between'>
|
||||||
<Description text={description[locale]} descriptionLineRows={1}></Description>
|
<Description text={descriptionText} descriptionLineRows={1}></Description>
|
||||||
<div onClick={e => e.stopPropagation()}>
|
<div onClick={e => e.stopPropagation()}>
|
||||||
<Action
|
<Action
|
||||||
pluginUniqueIdentifier={plugin_unique_identifier}
|
pluginUniqueIdentifier={plugin_unique_identifier}
|
||||||
|
Loading…
Reference in New Issue
Block a user