T
TanStack10mo ago
other-emerald

Dynamic root path

Hi! I have an app that is dealing with internationalisation. My route structure is something like / /about /whatever And I want to add additional paths that immediately target specific locales; /en /en/about /en/whatever What’s the recommended approach here? Is there a way to do it without duplicating everything to use $locale?
5 Replies
dependent-tan
dependent-tan10mo ago
if /about uses the default language, just redirect to /<default_language>/about could maybe be done through a splat route
other-emerald
other-emeraldOP10mo ago
I just tried splat and it seems to really overcomplicate the build in terms of typesafety, notfound boundaries etc etc.
other-emerald
other-emerald10mo ago
i believe this is not supported yet, this is also a deal breaker for me, we would need something like remix optional params, or always have a prefix for a language
afraid-scarlet
afraid-scarlet10mo ago
I also wondered about this today. I really like how nextjs handles it in the old pages router (https://nextjs.org/docs/pages/building-your-application/routing/internationalization#sub-path-routing)
Routing: Internationalization | Next.js
Next.js has built-in support for internationalized routing and language detection. Learn more here.
adverse-sapphire
adverse-sapphire10mo ago
optional path segments are on our backlog

Did you find this page helpful?