Facing difficulties with nuxt routing and i18n

pirony
35
pirony
commented 2 years ago

Hi there!
I'd like my generated routes to be:

/
/:category
/:category/:slug
/en/
/en/:category
/en/:category/:slug

The problem is that :category overrides /en, so when I visit "http://localhost:3000/en" the _category.vue is used instead of index.vue.
It seems logical afterwards…but how can I avoid this?
What should be my pages folder structure to achieve the result above ? (Nuxt i18n example shows only static routes config)
Thx

0
alexchopin
4.6k
alexchopin
commented 2 years ago

Hi @pirony, which version of nuxt are you using?

0
pirony
35
pirony
commented 2 years ago

Hi @alexchopin , thx for answering.
I'm using nuxt-community's starter template, shipped with nuxt v1.0.0rc11

0
cesasol
640
cesasol
commented 2 years ago

I have alse made a multilang site, and the way that I managed to solve the problem was to always have a /LANG/ route with the middleware, that way you can have all of your routes inside the _lang folder, even if it is nested or wildcard. And for the base index you only import/export the lang index, for example, in the project that i talk about the pages structure was this:

pages
├── index.vue
└── _lang
    ├── conoce.vue
    ├── hire-us.vue
    ├── index.vue
    ├── know.vue
    ├── saiba.vue
    ├── services.vue
    ├── servicios.vue
    ├── servicos.vue
    ├── _slug*.vue
    └── yago-de-marta.vue
0
pirony
35
pirony
commented 2 years ago

Hi @cesasol , and thanks for answering!
yes It's the solution I'm using ATM… but I'd really like to get rid of that '/fr/' part when current locale is the main language. :)

0
Informations
QuestionUnresolved
#c1690 - Created 2 years ago