【发布时间】:2023-03-15 21:46:02
【问题描述】:
我有一个名为“选项”的对象数组,我将其用作下拉/选择 Material-UI 组件的道具。我想在标签上使用 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;
【问题讨论】:
-
“我尝试使用 {t('key')} 但它不允许” - 你是什么意思?你有错误吗?
-
需要标识符。 ts(1003)
-
您可以查看演示吗:codesandbox.io/s/demo-4gnl4
标签: json next.js internationalization i18next next-i18next