Open rinart73 opened 1 year ago
Does checking the rest param in your load
doing a throw error(404, 'whatever')
if it's zero-length work?
Not really, because it would use +layout.svelte
and +error.svelte
from the routes/[...news=news]/[slug]/
directory instead of the expected routes/
. So essentially it would be treated like a missing news post instead of a missing top level page.
Even then, I think rest parameters aren't very good choice for my specific task since they I won't be able to track nested translateable URLs like /locale/translate1/translate2
. I guess focusing on https://github.com/sveltejs/kit/issues/4500 would be better.
Describe the problem
I'm trying to make a multilingual website with localized URLs. I have been advised to use the following structure:
[...news=news]
[slug]
src/params/news.ts:
Expected behaviour:
/news
- News list page in English/news/foo
- "Foo" news post in English from DB/ru/novosti
- News list page in Russian/ru/novosti/foo
- "Foo" news post in Russian from DB/ru/news
- 404/novosti
- 404/barbaz
- 404Actual behaviour:
/novosti
- "Novosti" news post in English/barbaz
- "Barbaz" news post in EnglishIf I understand correctly this happens because in the past rest parameters were changed to allow zero-length ( https://github.com/sveltejs/kit/issues/554 ), in which case a corresponding matcher doesn't run on them.
Describe the proposed solution
Maybe allow to specify which rest parameters can have zero-length and which can't?
Alternatives considered
Initially I thought of a simpler solution, but it's currently not supported because there is no way to read already matched "parent" paramerers ( https://github.com/sveltejs/kit/issues/4500 ).
[lang=lang]
[news=news]
[slug]
If everything else fails I guess I'll have to abandon the idea of localizing URLs, even though it's nice for usability.
Importance
would be nice to have
Additional Information
No response