yo-next-auth/components/translate-client-fragment.tsx

24 lines
498 B
TypeScript

import { useI18n } from '@/locales/client'
export const __ = (key: any, params?: any): React.ReactNode => {
const t = useI18n()
if (key.startsWith('["')) {
const data = JSON.parse(key)
if (data.length > 1) {
key = data.shift()
// @ts-ignore
return t(key, ...data)
}
}
return t(key, params)
}
const TranslateClientFragment = ({ message, args }: { message: any, args?: any }) => {
return <>{__(message, args)}</>
}
export default TranslateClientFragment