#I18n custom path not working

1 messages · Page 1 of 1 (latest)

hallow spindleBOT
#

Hi @tidal reef. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

Based on the information provided in the knowledge sources, I can help you with your i18n custom path routing issue in Nuxt. It seems that you're trying to set up a custom route for a dynamic page, but the configuration you've shown might not be in the correct format or location.

To set up custom routes with i18n in Nuxt 3, you should configure it in your nuxt.config.ts file. Here's how you can correctly set it up:

export default defineNuxtConfig({
  modules: ['@nuxtjs/i18n'],
  i18n: {
    vueI18n: './i18n.config.ts',
    locales: [
      { code: 'en', iso: 'en-US' },
      { code: 'fr', iso: 'fr-FR' }
    ],
    defaultLocale: 'en',
    customRoutes: 'config',
    pages: {
      'lesson/[id]': {
        en: '/library/lessons/[id]',
        fr: '/bibliotheque/lecons/[id]'
      }
    }
  }
})

A few key points to note:

  1. Make sure you have the @nuxtjs/i18n module installed and added to your modules array.
  2. The pages configuration should be inside the i18n object in your Nuxt config.
  3. The key for your custom route should match the file structure in your pages directory. In this case, it should be 'lesson/[id]' instead of 'lesson_[id]'.
  4. Set customRoutes: 'config' to enable custom route configuration.

If you've set this up correctly and it's still not working, you might need to check a few other things:

  1. Ensure that your pages directory structure matches the configuration.
  2. Make sure you're using the latest version of @nuxtjs/i18n compatible with Nuxt 3.
  3. If you're using a separate i18n config file, make sure it's properly set up and linked in your Nuxt config.

If you're still experiencing issues after making these changes, you might want to check the Nuxt i18n documentation for any recent updates or specific requirements for your Nuxt version.

#

Stack Overflow: Dynamic routing in Nuxt 3 with I18n provides some additional context on setting up dynamic routes with i18n in Nuxt 3, which might be helpful for your specific use case.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: