小编rkr*_*s26的帖子

NextJS 国际化路由(本地化 slugs)

我有一个使用 i18n 进行国际化路由的网站,它工作正常,但现在我们也想翻译、本地化 slugs。

页面结构

例如,我们有这个路线/integrations-and-plugins 例如:3 个语言环境,en de 和 hu 我们希望:

  • /en/集成和插件/
  • /de/集成和插件/
  • /hu/integraciok-es-pluginok/

(+此外它还有一个集成和插件/*id,但并不重要)

这是我的下一个配置相关部分:

const bundleAnalyzer = require('@next/bundle-analyzer')({
  enabled: !!process.env.BUNDLE_ANALYZE,
})

module.exports = bundleAnalyzer({
  images: {
    domains: ['cdn.builder.io'],
  },
  async headers() {
    return [
      {
        source: '/:path*',
        headers: [
          // this will allow site to be framed under builder.io for wysiwyg editing
          {
            key: 'Content-Security-Policy',
            value: 'frame-ancestors https://*.builder.io https://builder.io',
          },
        ],
      },
    ]
  },
  async rewrites() {
    return [
      {
        source: '/hu/integracios-es-ellenorzesi/',
        destination: '/hu/integrations-and-plugins/',
        locale: false,
      }, …
Run Code Online (Sandbox Code Playgroud)

localization routes internationalization next.js

5
推荐指数
1
解决办法
3379
查看次数