从api端点加载next-i18next中的i18n资源,不触发http请求



我目前正试图将next-i18nexti18next-http-backend集成到我的nextjs项目中,以便从后端端点加载本地化定义。

使用以下配置,但没有http请求到后端也不打印到控制台错误。

export default appWithTranslation(App, {
i18n: {
defaultLocale: 'en',
locales: ['en', 'de', 'fr'],
},
backend: {
loadPath: 'http://localhost:5000/api/v2/myproject/translations/{{lng}}/{{ns}}',
allowMultiLoading: false,
parse: (data: any) => {
console.log('parse is called')
return data
},
request: (options, url, payload) => {
console.log(options, url, payload)
},
},
debug: true,
serializeConfig: false,
use: [I18NextHttpBackend],
})

在我的nextjs页面,我也调用serverSideTranslations

我遇到了同样的问题,请注意,如果您注释掉serverSideTranslations,那么将会有一个网络请求

最新更新