l10n with named templates #4682
floratmin
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I just found an easy way for creating a svelte kit app with localized routes. For example i want to have the following page structure:
for this I create the following files:
__layout-sl.svelte
Here I get the locale from the url and set it in my store[email protected]
This sets up the translation store for the current locale and the content for the local root page[email protected]
Same as [email protected] but with translations and content for about page[email protected]
Same as [email protected] but with translations and content for about/latest-news pageThe non layout svelte files are all empty. So it is easy to create the files from a mapping of the file names of the layout files and the desired localized route:
Which will generate the following empty
.svelte
files:[email protected]
[email protected]
[email protected]
de/[email protected]
about/latest-news@about__latest_news.svelte
de/ueber/letzte-nachrichten@about__latest_news.svelte
And voila I have localized routes which can be pre-rendered easily. This could be used as a starting point for integrating the localization of routes in svelte kit.
Beta Was this translation helpful? Give feedback.
All reactions