#I18n custom path not working
1 messages · Page 1 of 1 (latest)
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:
- Make sure you have the
@nuxtjs/i18nmodule installed and added to your modules array. - The
pagesconfiguration should be inside thei18nobject in your Nuxt config. - The key for your custom route should match the file structure in your
pagesdirectory. In this case, it should be'lesson/[id]'instead of'lesson_[id]'. - 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:
- Ensure that your
pagesdirectory structure matches the configuration. - Make sure you're using the latest version of
@nuxtjs/i18ncompatible with Nuxt 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.