SvelteKit translated route parameters. #434
-
Hi there, What I will like to achieve:
Keywords magic and waterfall I would like to translate in typesafe-i18n, so the links I will create like:
and
post.locale I will get from outside API or will be hardcoded to specific languages. The problem here is: If I navigate to /xx/xxx, the route for keyword magic will always be loaded.
This will work. But is not great, not even good if the website will be large. I would want to ask If there is a better approach for this with typesafe-i18n and SvelteKit. The best what I came up with is an idea to map an array of translations for a specific key, and then use it in the route param. I will be very grateful for a solution or any hints. Regards, |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
You can take a look at the |
Beta Was this translation helpful? Give feedback.
You can take a look at the
localeTranslations
object in/src/i18n/i18n-util.sync
. There you have all translations as a regular JavaScript object. You can iterate over it and map it to the specific structure you need for the locale matcher function.