2

由于添加了 basePath ,语言环境文件得到了 404 ,

我尝试过的 i18n.tsx

  const NextI18NextInstance = new NextI18Next({
  defaultLanguage: 'en',
  otherLanguages: ['de'],
  fallbackLng: 'en',
  localeSubpaths,
  localePath: path.resolve('./public/static/locales'),
})

Updated above code with basePath like below ,

  const NextI18NextInstance = new NextI18Next({
  defaultLanguage: 'en',
  otherLanguages: ['de'],
  fallbackLng: 'en',
  localeSubpaths,
  localePath: path.resolve('./<basepath>/public/static/locales'),
})

但这会引发内部服务器错误。

4

1 回答 1

0

大家好,通过 i18n.tsx中的此配置修复它需要在i18n.tsx中添加后端

  const NextI18NextInstance = new NextI18Next({
     backend: {
      loadPath: `https://${apiDomainName}/<basepath>/static/locales/{{lng}}/{{ns}}.json`,
     },
  })

apiDomainName可以是 localhost:3000 或www.your-webiste.com

于 2020-12-11T05:19:25.653 回答