i18n icon indicating copy to clipboard operation
i18n copied to clipboard

Add one more way to define custom routes. 'named-config'

Open tirojal opened this issue 2 years ago • 2 comments

Describe the feature

I have a project that heavily relies on several modules injecting pages. It is used to create websites for different countries by feeding country-config into nuxt-config. As a result, each module may inject a different set of pages based on the configuration.

Currently, I have found no way to define custom routes for pages injected through modules. I cannot use customRoutes: 'page' because it would require modifying all modules whenever we release the website for a new country. Also, I cannot use customRoutes: 'config' since it cannot resolve AnalyzedNuxtPageMeta for injected pages.

I wrote some details in discussions few days ago: https://github.com/nuxt-modules/i18n/discussions/2398

I'd like to have an ability to define customRoutes based on route name instead of fs-like path. So next 2 blocks will give same result:

i18n: {
  customRoutes: 'config',
  pages: {
    'my/[param]/page': {
      en: 'my/[param]/page',
      de: 'mein/[param]/seite'
    }
  }
}
i18n: {
  customRoutes: 'named-config',
  pages: {
    'my-param-page': { 
      en: 'my/:param()/page',
      de: 'mein/:param()/seite'
    }
  }
}

Additional information

  • [X] Would you be willing to help implement this feature?
  • [ ] Could this feature be implemented as a module?

Final checks

tirojal avatar Sep 13 '23 12:09 tirojal

Thank you for your reporting!

I've just put the my opinion for your proposal. https://github.com/nuxt-modules/i18n/discussions/2398#discussioncomment-6997864

kazupon avatar Sep 14 '23 06:09 kazupon

Also having issue to use custom routes for pages injected trough module. Is there any workaround ATM ?

lateek35 avatar Jul 11 '24 08:07 lateek35

We will soon support adding custom routes via definePageMeta as well https://github.com/nuxt-modules/i18n/pull/3578, we currently have no plans to add additional methods of configuring custom routes.

You may have been experiencing issues with injected routes in hooks due to limitations with module registration ordering, this may have been resolved in the latest versions of this module. In any case I will be closing this issue, please open an issue with a minimal reproduction if your injected pages are not being localized correctly 🙏

BobbieGoede avatar May 23 '25 09:05 BobbieGoede