nuxt-modules / i18n

I18n module for Nuxt
https://i18n.nuxtjs.org
MIT License
1.73k stars 479 forks source link

defineI18nRoute does not work #1958

Closed visko83 closed 9 months ago

visko83 commented 1 year ago

Environment

Reproduction

nuxt.config.ts:

...
customRoutes: 'config',
    pages: {
      blog: {
        hu: '/jegyzet',
        en: '/blog',
      },
    },

pages/blog.vue exists and routing works for this page.

But routing defined in pages/agency.vue has no effect, /iroda cannot be found, agency.vue's content:

<script setup lang="ts">
defineI18nRoute({
  paths: {
    hu: '/iroda',
    en: '/agency',
  },
});
</script>

https://stackblitz.com/edit/github-w7smfy-beadgd

Describe the bug

Paths defined in pages (defineI18nRoute in <script setup>) don't work, in the reproduction steps above /iroda or /en/agency goes to 404.

Additional context

No response

Logs

No response

icelandcruiser commented 1 year ago

I had to remove customRoutes: 'config' from the nuxt.config.ts to use defineI18nRoute

alexelker commented 9 months ago

Did anyone solve this?

BobbieGoede commented 9 months ago

Sorry for the late response, customRoutes has to be set to 'page' (which is the default) to be able to set paths using defineI18nRoute, see https://i18n.nuxtjs.org/options/routing#customroutes and https://i18n.nuxtjs.org/guide/custom-paths for more info.