fix: i18n

This commit is contained in:
StyleZhang 2024-11-06 15:23:38 +08:00
parent 9025e85ca5
commit 21b3703bd8
2 changed files with 9 additions and 4 deletions

View File

@ -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

View File

@ -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 (
<>