From 88dbf639e074e252e3da43e370197cc5e34b0041 Mon Sep 17 00:00:00 2001 From: Joel Date: Fri, 11 Oct 2024 14:24:43 +0800 Subject: [PATCH] chore: enchance locale props --- web/app/(commonLayout)/plugins/test/card/page.tsx | 6 ++++++ web/app/components/plugins/card/index.tsx | 7 ++----- .../install-plugin/install-from-marketplace/index.tsx | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/web/app/(commonLayout)/plugins/test/card/page.tsx b/web/app/(commonLayout)/plugins/test/card/page.tsx index bd1169cd91..e7ba6849bb 100644 --- a/web/app/(commonLayout)/plugins/test/card/page.tsx +++ b/web/app/(commonLayout)/plugins/test/card/page.tsx @@ -4,8 +4,11 @@ import { extensionDallE, modelGPT4, toolNotion } from '@/app/components/plugins/ import PluginItem from '@/app/components/plugins/plugin-item' import CardMoreInfo from '@/app/components/plugins/card/card-more-info' import InstallModelItem from '@/app/components/plugins/install-model-item' +import { getLocaleOnServer } from '@/i18n/server' const PluginList = async () => { + const locale = getLocaleOnServer() + const pluginList = [toolNotion, extensionDallE, modelGPT4] return ( @@ -22,6 +25,7 @@ const PluginList = async () => {
@@ -30,6 +34,7 @@ const PluginList = async () => {
@@ -49,6 +54,7 @@ const PluginList = async () => { } diff --git a/web/app/components/plugins/card/index.tsx b/web/app/components/plugins/card/index.tsx index 0936541b88..b67c68c7e4 100644 --- a/web/app/components/plugins/card/index.tsx +++ b/web/app/components/plugins/card/index.tsx @@ -8,17 +8,16 @@ import Title from './base/title' import OrgInfo from './base/org-info' import Description from './base/description' import cn from '@/utils/classnames' -// import { getLocaleOnServer } from '@/i18n/server' import type { Locale } from '@/i18n' type Props = { className?: string payload: Plugin + locale: Locale // The component is used in both client and server side, so we can't get the locale from both side(getLocaleOnServer and useContext) showVersion?: boolean installed?: boolean descriptionLineRows?: number footer?: React.ReactNode - clientLocale?: Locale serverLocale?: Locale } @@ -29,10 +28,8 @@ const Card = ({ installed, descriptionLineRows = 2, footer, - clientLocale, - serverLocale, + locale, }: Props) => { - const locale = clientLocale || serverLocale || 'en' const { type, name, org, label } = payload return ( diff --git a/web/app/components/plugins/install-plugin/install-from-marketplace/index.tsx b/web/app/components/plugins/install-plugin/install-from-marketplace/index.tsx index dd80fcce55..36e813bf68 100644 --- a/web/app/components/plugins/install-plugin/install-from-marketplace/index.tsx +++ b/web/app/components/plugins/install-plugin/install-from-marketplace/index.tsx @@ -39,7 +39,7 @@ const InstallFromMarketplace: React.FC = ({ onClose ))}