Replies: 1 comment
-
|
hey, the issue is that you are adding pages that already have the locale prefix from i18n module, and then the module adds it again. instead of manually prefixing in your module, let nuxt-i18n handle the prefixes. try this: // modules/custom-pages.ts
import { defineNuxtModule, extendPages } from "@nuxt/kit";
export default defineNuxtModule({
setup(options, nuxt) {
extendPages((pages) => {
// add base pages WITHOUT locale prefix
pages.push({
name: "product-a",
path: "/products/product-a",
file: resolve(__dirname, "../pages/custom/product-a.vue"),
meta: {
// tell i18n which locales this page supports
nuxtI18n: {
locales: ["de", "en"]
}
}
});
});
}
});the key points:
if you need totally different pages per locale (not just translated), another approach: // nuxt.config.ts
i18n: {
customRoutes: "config",
pages: {
"products/product-a": {
de: "/produkte/produkt-a",
en: "/products/product-a"
}
}
}this way you define custom paths per locale in config instead of module. also check your module load order in nuxt.config - your custom module should load BEFORE @nuxtjs/i18n so it can process your pages correctly. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have this page structure:
What I want to achieve:
product-a.vueandproduct-b.vue) using custom pages. (these need to be different files because the content will be entirely different, not just translated)My current i18n configuration:
The problem:
I tried creating a custom module to register the locale-specific pages:
But this creates double-prefixed routes like
/en/de/product-ainstead of the expected/de/products/product-a.How can I properly configure this setup? Any help would be appreciated.
Beta Was this translation helpful? Give feedback.
All reactions