PC_001
PC_001
NNuxt
Created by PC_001 on 1/10/2025 in #❓・help
Nuxt i18n pages:extend
Yeah the whole point is that this:
hooks: {
'pages:extend' (pages) {
// add a route
pages.push({
name: 'profile',
path: '/profile',
file: '~/extra-pages/profile.vue'
})
hooks: {
'pages:extend' (pages) {
// add a route
pages.push({
name: 'profile',
path: '/profile',
file: '~/extra-pages/profile.vue'
})
Will endup creating those routes: {name: "profile___en", path: "/profile"}, {name: "profile___fr", path: "/profile"} I have no way to tell the french path from this NuxtPage schema, OR inject them with my own name appending ___en/fr telling nuxt NOT TO localize them afterwards, even if i was to OVERWRITE (or dare thinking it would) this french path in the i18n pages. This is actually triggered afters i18n initialization, so this would be the last known path for french profile___fr And like i said if we were to inject manually both english and french route for profile with their own path like This:
hooks: {
'pages:extend' (pages) {
// add a route
pages.push({
name: 'profile___en',
path: '/profile',
file: '~/extra-pages/profile.vue'
})

// add a route
pages.push({
name: 'profile___fr',
path: '/whatever-fr',
file: '~/extra-pages/profile.vue'
})
hooks: {
'pages:extend' (pages) {
// add a route
pages.push({
name: 'profile___en',
path: '/profile',
file: '~/extra-pages/profile.vue'
})

// add a route
pages.push({
name: 'profile___fr',
path: '/whatever-fr',
file: '~/extra-pages/profile.vue'
})
This would create routes like this: {name: "profile___en___en", path: "/profile"}, {name: "profile___en___fr", path: "/profile"},{name: "profile___fr___en", path: "/whatever-fr"}, {name: "profile___fr___fr", path: "/whatever-fr"}
5 replies