T
TanStack13mo ago
exotic-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
ratty-blush
ratty-blush13mo ago
if /about uses the default language, just redirect to /<default_language>/about could maybe be done through a splat route
exotic-emerald
exotic-emeraldOP13mo ago
I just tried splat and it seems to really overcomplicate the build in terms of typesafety, notfound boundaries etc etc.
sensitive-blue
sensitive-blue12mo 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
extended-salmon
extended-salmon12mo 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.
fascinating-indigo
fascinating-indigo12mo ago
optional path segments are on our backlog

Did you find this page helpful?