Closed LorisSigrist closed 1 month ago
It's the same with Sveltekit. I'd like to have separate domains for each language, but now I seem to be forced to use /en/, /nl/ prefixes just so I can have support for different languages...
Domain based routing is something we want to support in sveltekit.
We probably can't use the same API as Next since there is no way to access cookies or request headers before reroute
ing, but it is a use-case we want to support.
Domain based routing is something we want to support in sveltekit.
We probably can't use the same API as Next since there is no way to access cookies or request headers before
reroute
ing, but it is a use-case we want to support.
Do you know when there's going to be work on that feature as I'd otherwise have to move to a different library as it's the only missing feature
Probably next Month
Right now we're focused on bringing Paraglide-Next to 1.0 and adding Plurals, Formatters and Markup to the message-format.
Sorry if this doesn't work for you.
Context
The Next Adapter already supports complex language-detection. However, the routing is very opinionated. It does not yet have the necessary Routing APIs to implement non-default routing logic such as domain based routing.
We don't want to add a config setting for every imaginable routing strategy. That would bloat the adapter, be a huge maintenance burden & blow up the bundle size.
Proposal
Define a "Routing Strategy" interface for defining how links should behave. Then pass the routing strategy to
createI18n
.From the developers perspective it would look like this:
The "strategy" would need to provide these functions:
With those functions it's possible to implement any imaginable i18n routing strategy.
We then use these functions to localize the Navigation APIs, including the
Link
component, redirect functions & all the other ones.To keep the initial setup as simple as possible, we will provide constructor functions to create these strategies for common use-cases. This keeps the config basically the same size, just with another wrapper function.
You would need to pair the routing-strategy with a language-detection middleware that detects the language & sets cookies appropriately. That's not hard, but it's something to keep in mind.
Pros
Cons