-
-
Notifications
You must be signed in to change notification settings - Fork 33
Description
Currently the loader function can not load translations dynamically, passing the current route or even parameters would allow for better usage.
My example use case would by I have and article that is located under article/[articleId], so once the user navigates to the article the translation for that article only should be loaded. I can do this by loading the correct translation from my DB in the +page.server.ts but doing it directly trough the translation library would be cleaner.
The current loader function is export type T = () => Promise<Translations.Input>;. A simple solution would just be to pass the current route to the loader like export type T = (route: string) => Promise<Translations.Input>;.
A more advanced version would be to allow parameters in the routes for a loader, similar to how sveltekit params work.
So for example defining the routes as /article/{articleId} (or article/[articleId]) and the loader as export type T = (params: {[key: string]: string}) => Promise<Translations.Input>; it would then pass
{
"articleId": "some_id"
}to the loader function.