我尝试在Nextjs项目中使用next-i18next包。在我的动态页面如:/blogs/[id]
部分,i18 n无法翻译页面,只能在服务器上显示其键,但在本地工作正常。
这是我在next-i18 next中的翻译代码:export async function getServerSideProps(context) { const { locale, params: { id }} = context; return { props: {...(await serverSideTranslations(locale))}}}
个
在服务器上,它只显示JSON键,我看不到任何翻译。(仅适用于动态页面)
我想这个问题是由于使用了amplify,我们需要对它进行一些配置。
1条答案
按热度按时间cbjzeqam1#
可能存在与解析消息/本地文件相关的问题,如next-i18 next本身的README中所述:
一些无服务器PaaS可能无法定位您的翻译路径,需要额外的配置。
尝试使用
path.resolve
添加区域设置的绝对路径,例如:字符串