我有一个页脚组件:
export default function Footer() {
const { t } = useTranslation("layout-footer");
const currentYear = new Date().getFullYear();
return (
<footer className='py-6 mt-20 border-t-[1px] border-opacity-50'>
<p className='text-sm text-center mb-6'>{t("addresses")}</p>
<p className='text-sm text-center mb-6'>
<Trans
i18nKey='information'
t={t}
components={{
currentYear,
link: (
<Link
href='https://www.signinsolutions.com'
className='text-green-600'
rel='noreferrer'
target='_blank'
>
Sign In Solutions
</Link>
),
}}
/>
</p>
</footer>
);
}
json文件:
{
"information": "© {{currentYear}} Sign In App Ltd is part of the {{link}} suite of brands providing global, cloud-based solutions to manage visitors, employees, workplaces and beyond."
}
我尝试了多种不同的东西没有成功-我只是不能得到似乎得到currentYear和链接组件呈现在我的翻译在同一时间-链接将永远是作为[Object object]
Screenshot
1条答案
按热度按时间3phpmpom1#
我建议在这个例子中使用i18next interpolation。让我为您提供解决方案的草案:
footer组件应该如下所示:
如果你想禁用转义,那么在你的翻译JSON文件中,请在打开双花括号
{{- variable_name}}
后使用小减号,就像这样: