-
-
Notifications
You must be signed in to change notification settings - Fork 483
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom route config doesn't cascade #3150
Comments
I see a few options for this:
pages: {
order: {
cascade: true,
hu: '/rendeles',
}
}
pages: {
'/order': {
hu: '/rendeles',
},
'*/page': {
hu: '/oldalon'
}
}
pages: {
'order/*': {
hu: '/rendeles/*',
},
'*/page/*': {
hu: '*/oldalon/*'
}
}
Like this: segments: {
'order': {
hu: 'rendeles',
}
} The last option has the advantage of giving the possibility to translate path in the middle of params which the first doesn't Here is a real world example Before: pages: {
'shop/[...category]/page/[page]': {
en: '/product-category/[...category]/page/[page]',
hu: '/termek-kategoria/[...category]/oldalon/[page]',
},
} After with option 2: pages: {
'/shop': {
en: '/product-category',
hu: '/termek-kategoria',
},
'*/page': {
en: '/page',
hu: '/oldalon',
}
} After with option 4: segments: {
'shop': {
en: 'product-category',
hu: 'termek-kategoria',
},
'page': {
en: 'page',
hu: 'oldalon',
}
} Looking for feedback on the prefered implementation for a PR |
I can see this getting complicated when multiple layers provide such configs, matching pages isn't straightforward when taking redirects and aliases into account (not sure if these are supported in the current implementation though). While your feature proposal is much appreciated 🙏 I'm not really convinced this functionality improves the dev experience enough to justify the maintenance and (potential) edge cases down the line. If your project has enough routes for this to be an issue I think writing a function to generate the config should make things easier 🤔 |
That would be the case for anyone using this lib TBH, because if you have a folder and say 4-5 pages in it, any translation of the root folder needs to be done for each component, so 5 times, and now imagine how it is when you have nested subfolders, it quickly becomes impossible to translate a folder path without writing either a hook to replace the name on all routes or a fs reader to generate the config.. This is really not the dev's place to do this as well, this is where the lib should step in and provide said function to generate the config The current implementation is simply not usefull and cannot be used for more advanced projects in it's current state Localization is meant to be done by less technical people and we need to be able to give them a way to easily translate paths without having to take care of all the parameters and duplication
They are not, a redirect needs to be specified like this currently
I don't see how this would create more edge cases and maintenance than the current implementation, because it provides literally the same feature, that is to change the path of a route depending on the locale, just with a better config api I already looked into implementing option 4 and it was pretty straightforward
I also imagine this could be complicated with layers, but why would anyone provide this config in the layer? This is translation and is only meant for the end config and this argument could also be used for the current implementation, this has always been a problem for any array/object config option and it has solutions: nuxt/nuxt#22196 |
Describe the feature
Assuming the following page structure
I would assume the following i18n config
To result in the following paths
Instead currently no modification is done, matching has to be done on the
vue
file name and match perfectlyResulting in
To get the desired behavior above we instead need to write this
This is very verbose, duplicates a lot of translated words and not practical when there is a lot of subroutes and attributes and we want them all to have the base translated, because we need to write one entry for every file that is created
Could we instead resolve routes in a cascading fashion, so if the config matches the start of the path we replace the matching part with what was configured? (Behind an option maybe)
Additional information
Final checks
The text was updated successfully, but these errors were encountered: