From 21b3703bd87ed0c2e2ec089e1a893fbec94d28bb Mon Sep 17 00:00:00 2001 From: StyleZhang Date: Wed, 6 Nov 2024 15:23:38 +0800 Subject: [PATCH] fix: i18n --- web/app/components/plugins/card/index.tsx | 3 ++- .../plugins/marketplace/description/index.tsx | 10 +++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/web/app/components/plugins/card/index.tsx b/web/app/components/plugins/card/index.tsx index c7acfbe428..b262727506 100644 --- a/web/app/components/plugins/card/index.tsx +++ b/web/app/components/plugins/card/index.tsx @@ -10,6 +10,7 @@ import Description from './base/description' import Placeholder from './base/placeholder' import cn from '@/utils/classnames' import { useGetLanguage } from '@/context/i18n' +import { getLanguage } from '@/i18n/language' export type Props = { className?: string @@ -39,7 +40,7 @@ const Card = ({ locale: localeFromProps, }: Props) => { const defaultLocale = useGetLanguage() - const locale = localeFromProps || defaultLocale + const locale = localeFromProps ? getLanguage(localeFromProps) : defaultLocale const { type, name, org, label, brief, icon, verified } = payload diff --git a/web/app/components/plugins/marketplace/description/index.tsx b/web/app/components/plugins/marketplace/description/index.tsx index 41888d3dbe..403478dfc7 100644 --- a/web/app/components/plugins/marketplace/description/index.tsx +++ b/web/app/components/plugins/marketplace/description/index.tsx @@ -1,12 +1,16 @@ -import { useTranslation as translate } from '@/i18n/server' +import { + getLocaleOnServer, + useTranslation as translate, +} from '@/i18n/server' type DescriptionProps = { locale?: string } const Description = async ({ - locale = 'en-US', + locale: localeFromProps, }: DescriptionProps) => { - const { t } = await translate(locale, 'plugin') + const localeDefault = getLocaleOnServer() + const { t } = await translate(localeFromProps || localeDefault, 'plugin') return ( <>