I18n-module: How to have multiple aliases for the same page?

Created on 22 Feb 2018  路  4Comments  路  Source: nuxt-community/i18n-module

I want URLs having 2 different patterns to point to the same page:

  • for cars with odd id: /en/car/1, /voiture/1
  • for cars with even id: /en/latest/2, /nouveau/2

(both should render the same /pages/cars/show.vue component)

Could this be implement with the current version? And I wonder how both routes: { ... } object and localePath( ... ) call should look.

Thanks for this module.

This feature request is available on Nuxt.js community (#c20)
feature-request wontfix

Most helpful comment

I was able to achieve this with declaring another path in extendRoutes instead of using alias by extending router module

extendRoutes (routes) {
  routes.push({name: 'old-path', path: '/old-path', component: '~pages/index.vue'})
}

I hope this i will be useful to others.

All 4 comments

Hi @adi-zz
This is currently not possible with current version but it would certainly be an interesting feature.
In the meantime you could probably "hack" your way to a solution by using other pages that export the page's module you'd like to translate, kinda like it's done in Nuxt's i18n official example: https://nuxtjs.org/examples/i18n

How can you use this when you have dynamic routes, i mean how do you pass params to a vue page

I was able to achieve this with declaring another path in extendRoutes instead of using alias by extending router module

extendRoutes (routes) {
  routes.push({name: 'old-path', path: '/old-path', component: '~pages/index.vue'})
}

I hope this i will be useful to others.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings