N
Nuxt2mo ago
hz2222

A page with multiple name

In Nuxt i18n, I want the /fizetes localized page to also open when visiting /plata.
5 Replies
kapa.ai
kapa.ai2mo ago
Hi @hz2222. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- To achieve multiple localized paths for a single page in Nuxt with @nuxtjs/i18n, you can use the i18n module's custom route mapping feature. This allows you to define multiple paths for the same page in your i18n configuration. For your case, if you want both /fizetes and /plata to open the same localized page, you can define both as custom routes for the same page component. Here’s how you can do it in your nuxt.config.ts:
export default defineNuxtConfig({
modules: ['@nuxtjs/i18n'],
i18n: {
// ...other i18n options
pages: {
fizetes: {
hu: ['/fizetes', '/plata'] // Both paths will render the same page in Hungarian
}
}
}
})
export default defineNuxtConfig({
modules: ['@nuxtjs/i18n'],
i18n: {
// ...other i18n options
pages: {
fizetes: {
hu: ['/fizetes', '/plata'] // Both paths will render the same page in Hungarian
}
}
}
})
This configuration tells Nuxt i18n to map both /fizetes and /plata to the same page for the Hungarian locale. When a user visits either path, the same page component will be rendered. Note: The knowledge sources confirm the use of the pages option for custom route mapping, but do not explicitly show mapping multiple paths to a single page. However, the structure of the pages option in the i18n config is designed for such use cases, and this approach aligns with the documented usage for custom routes and dynamic routing in Nuxt i18n Dynamic routing in Nuxt 3 with I18n. If you encounter issues, please check the official Nuxt i18n documentation for the latest syntax and features, as the knowledge sources do not provide a direct example of multiple paths per locale. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai2mo ago
<@993174034940444752> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
hz2222
hz2222OP2mo ago
@kapa.ai i want to load it in romanian lang on /plata
kapa.ai
kapa.ai2mo ago
Let me check the knowledge base for you again. One moment! :books: ---------------------- To load your payment page in Romanian when visiting /plata, you should use the pages option in your Nuxt i18n configuration to map the Romanian locale (ro) to the /plata path. Here’s how you can do it:
export default defineNuxtConfig({
modules: ['@nuxtjs/i18n'],
i18n: {
// ...other i18n options
pages: {
fizetes: {
ro: '/plata'
}
}
}
})
export default defineNuxtConfig({
modules: ['@nuxtjs/i18n'],
i18n: {
// ...other i18n options
pages: {
fizetes: {
ro: '/plata'
}
}
}
})
This configuration tells Nuxt i18n that when the locale is Romanian (ro), the route /plata should load the fizetes page. This approach is supported by the documented usage of the pages option for custom route mapping in Nuxt i18n Dynamic routing in Nuxt 3 with I18n. If you want /fizetes to be available in other languages, you can add those as well:
pages: {
fizetes: {
hu: '/fizetes',
ro: '/plata'
}
}
pages: {
fizetes: {
hu: '/fizetes',
ro: '/plata'
}
}
This way, /fizetes will load the page in Hungarian, and /plata will load it in Romanian. If you need to support multiple paths for the same locale, the knowledge sources do not explicitly confirm this, so you may need to consult the official Nuxt i18n documentation for advanced use cases. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai2mo ago
<@993174034940444752> Kapa.ai is still learning and improving, please let me know how I did by reacting below.

Did you find this page helpful?