i18nest 翻译工作仅在我的 Next 应用程序的根目录下进行

问题描述 投票:0回答:1

当我位于下一个应用程序的根目录时:http://localhost:3000/en,使用 i18next 翻译,后者工作正常。但是,当我浏览到另一个网址时,翻译不再像此链接一样工作:http://localhost:3000/en/survey

module.exports = {
  i18n: {
    // all the locales supported in the application
    locales: ['fr', 'en', 'ar'],
    // the default locale to be used when visiting
    // a non-localized route (e.g. `/about`)
    defaultLocale: 'fr',
  },
};

当我在仪表板处时,翻译工作正常。然而。当我浏览到不同的页面时,它们不适用

next.js routes translation i18next rect
1个回答
0
投票

确保每个页面都有 getServerSideProps 或 getStaticProps 函数,以及从 next-i18next 导入的 useTranslation...

并将其与以下示例进行比较:https://github.com/i18next/next-i18next/blob/master/examples/simple/pages/second-page.tsx

© www.soinside.com 2019 - 2024. All rights reserved.