35 likes
·
2.6K reads
8 comments
Very nice explained Andreas, great code snippets to code and learn along.
Thanks for the awesome content Andreas! Best article about typesafe-i18n that I found! I am using routing for lang detection, but the content of the page is changing when I hover the links to different lang version (I am using hrefs to /de, /en,..). I know I can disable data preload in sveltekit, but is there any better solution? Thank you!
Hi Pavel, glad you like the article! :) I see the problem. In this case I'd pass the "LINK" translation string/locale as page data instead, so it's definitely available.
Thank you so much for this article! It made it so clear and simple to follow along and saved me so much time. I'd like to ask you if you prefer using the route- or cookie-way of doing it? I think using a cookie would be simpler and easier to maintain but I can't see what are the disadvantages?
Hi Tobias, I'm glad I could make things easier for you. :) I can't say I have a preference, the method to use depends on the site and its requirements. Cookies makes for cleaner routes, but from a SEO perspective it could be better to use the route way, for example. It's hard to say without knowing more about the specific site you're making.
Andreas Söderlund Ok, thank you for your answer. I don't have any specific requirements for it's a side-project I'm working on but I thought it could have implications for seo but wasn't sure about it. I'll try to find some resources to make a more profound decision.
Great article! The only two things that I am missing is the automatic detection of the browser language through the header and a language switcher - could you possibly add this in the future? 🙏
Hi Jens, I think I'll leave that as an exercise to the reader, it should be quite easy to modify the cookie example at the end to look at the relevant headers instead of the cookie data.