我有一个名为"Options“的对象数组,用作下拉/选择Material组件的支柱。我想在标签上使用next-i18next库。我已经成功地实现了所有的下一个应用程序,就像文档解释的那样。我尝试使用{t('key')},但它不允许。
import { useTranslation } from 'next-i18next'
const UsersPage = () => {
const { t } = useTranslation('user');
const Options = [
{ value: 'fullName', label: 'Nome' },
{ value: 'cpf', label: 'CPF' },
{ value: 'id', label: 'Padrão' },
]
...rest of the component
}
export const getStaticProps = async ({ locale }) => ({
props: {
...await serverSideTranslations(locale, ['user', 'home']),
},
})
export default UsersPage;发布于 2021-12-28 16:12:16
母亲的回答是正确的:
`${t("key")}`在JSON内部或在道具中构建字符串,如
const since = `${t('since')}`;
const until = `${t('until')}`;
...
<ListItemText
primary={value.name}
secondary={since + value.beginDate + until + value.endDate}
/>https://stackoverflow.com/questions/70439586
复制相似问题