Closed Rigo-m closed 4 weeks ago
As a side note: @s00d, can I buy you a coffee for the amazing work you are doing? I don't see any sponsorship link in your github :D
No, they must not be deleted under any circumstances, it will break Nuxt.
buy you a coffee
As a side note: @s00d, can I buy you a coffee for the amazing work you are doing? I don't see any sponsorship link in your github :D
Regarding support, I would gladly add a support link, but unfortunately, I don't have the option to do so.
As a side note: @s00d, can I buy you a coffee for the amazing work you are doing? I don't see any sponsorship link in your github :D
added a support link
No, they must not be deleted under any circumstances, it will break Nuxt.
@s00d is this really necessary? From my understanding nuxt-i18n had the same issue and they found a way to remove the unprefixed routes, see: https://github.com/nuxt-modules/i18n/pull/2538
Thanks for the work!
No, they must not be deleted under any circumstances, it will break Nuxt.
@s00d is this really necessary? From my understanding nuxt-i18n had the same issue and they found a way to remove the unprefixed routes, see: nuxt-modules/i18n#2538
Thanks for the work!
The main route definitely can't be deleted, the others can be tried, but I'm not sure how best to check it. Also, you need to keep in mind that there's a lot of functionality that could break.
No, they must not be deleted under any circumstances, it will break Nuxt.
@s00d is this really necessary? From my understanding nuxt-i18n had the same issue and they found a way to remove the unprefixed routes, see: nuxt-modules/i18n#2538
Thanks for the work!
Is it really critical for you to remove the default routes? I've basically implemented it, though I had to add some workarounds, and it seems to work. If it is important, could you please explain why you need this and what problems you're encountering? I'm still considering whether it's worth releasing.
I wouldn't say it is critical but may make a difference.
E.g. I am maintaining an multilanguage application which is available in 27 languages. Right now it has about 1137 routes. Every new route - which is translated - will add 27 routes + 1 without a prefix. I would be happy for every route which is not added.
I wouldn't say it is critical but may make a difference.
E.g. I am maintaining an multilanguage application which is available in 27 languages. Right now it has about 1137 routes. Every new route - which is translated - will add 27 routes + 1 without a prefix. I would be happy for every route which is not added.
My module works differently; each new language does not add routes. You will always have the number of routes multiplied by 2. That was its main idea. So, if you have 100 routes, with my module, there will always be 200, regardless of how many locales you have, whether it's 2 or 202 (unless there are exceptions, such as using custom routing on pages).
The problem is that right now, I can't properly test the functionality of the new logic. I simply don't have a test project that could cover all of Nuxt's functionality and has a large number of routes and languages. If you are able to test its functionality after I release it, I can do that, but I will then need feedback from you.
Also, in your case, I would highly recommend looking into customRegexMatcher. It speeds up locale matching for the router. Thanks for this @Rigo-m The idea is that the regex becomes something like [a-z]{2}, and it makes it much easier for the router to handle routing.
Just a heads-up, this functionality will break integration with other modules. For example, if you're using an SEO module, it will stop working.
I will create an simplified stackblitz example for my use-case. I am using globalLocaleRoutes
for most of the routes (all the routes that needs to be translated). Maybe I did miss something.
@s00d here you go: https://stackblitz.com/~/github.com/FlorianWerndl/n3-i18n-micro
@s00d here you go: https://stackblitz.com/~/github.com/FlorianWerndl/n3-i18n-micro
try v1.30.0 https://github.com/s00d/nuxt-i18n-micro/blob/main/test/n3.test.ts
Removed default routes and fixed links, also added your project to the tests.
I've updated my repo to use 1.30.0 but I can't see any difference on the number of routes and unprefixed routes still exist.
Url encoding seems to be corrected though 👍
fixed, try v1.30.2
With v1.30.2 just some unpefixed routes have been deleted. (all the unprefixed catch all, see screenshot for comparison)
v1.30.0
v1.30.2
With v1.30.2 just some unpefixed routes have been deleted. (all the unprefixed catch all, see screenshot for comparison)
v1.30.0
v1.30.2
It's impossible to delete the remaining routes; I need to somehow link a custom route with the original one, and the custom route should be found via the default route
With v1.30.2 just some unpefixed routes have been deleted. (all the unprefixed catch all, see screenshot for comparison)
v1.30.0
v1.30.2
I finally figured out how to remove almost all routes. Try version 1.31.0. I added a custom-fallback-route, which handles redirects for includeDefaultLocaleRoute. Now, there should only be local routes + 1 custom-fallback-route + the root route, and the disabled routes if you set false for the route in globalLocaleRoutes.
I've did a POC on the application I mentioned earlier and - without final testing - it seems that I could reduce the number of routes from 1135
with nuxt-i18n
to 850
with nuxt-i18n-micro
. 🚀
I've updated my repo and I even see some more potential. Imagine passing something like the below to globalLocaleRoutes
...
info: {
de: '/info',
fr: '/info',
ru: '/информация',
...
},
This would create a route for every translation like /de/info
and ru/информация
and so on..
But some of the have overlapping translations like fr
and de
. This could be consolidated to (de|fr)/info
.
Maybe by just not adding de
and fr
to the object of info
or by passing false
as a value?
I've did a POC on the application I mentioned earlier and - without final testing - it seems that I could reduce the number of routes from
1135
withnuxt-i18n
to850
withnuxt-i18n-micro
. 🚀I've updated my repo and I even see some more potential. Imagine passing something like the below to
globalLocaleRoutes
... info: { de: '/info', fr: '/info', ru: '/информация', ... },
This would create a route for every translation like
/de/info
andru/информация
and so on.. But some of the have overlapping translations likefr
andde
. This could be consolidated to(de|fr)/info
. Maybe by just not addingde
andfr
to the object ofinfo
or by passingfalse
as a value?
I initially planned it this way, but there’s a problem: I’m searching for routes by name, and I need to come up with logic that would allow me to find the right route. Right now, I have no ideas, which is why it’s done this way.
So, it works in a way that, when creating a custom route, a new route is created from the locale-new
route, for example, with the name locale-new-en
. After that, when switching locales, the search occurs by name, either locale-new
or locale-new + selected locale
. But if you combine them, it’s unclear how to find the route. Path matching is not an option, as it’s custom. Coming up with a common name doesn’t work. Setting up metadata would increase routing complexity, so it’s unclear how to make it work.
Why, in your case, don’t you use parameters in the links? For instance, /:locale(en|de|ru)/:name/:key
would work perfectly for you. This approach would solve all your issues. You could create a hidden page with all the links or a module that generates all the links, or fetch all values from the backend. In general, there are many options, and they’re all simpler than what you currently have.
Right now, I think I don't really understand what you mean - but I will make my mind about it. btw. I have a page where these links are generated based on values from the backend.
https://github.com/Rigo-m/nuxt-i18n-micro-test
In this reproduction, I should theoretically have 2 routes, instead I have 4
Are / and /test routes required or can they be removed? When we have 50/60 routes inside an application, it can be good for the sake of performance to remove non-localized routes. Am I missing something?