0

我目前正在尝试将其集成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.

4

0 回答 0