Internationalization (i18n) of Svelte Apps
Internationalization is the process of making a website that is adaptable to different locales (regions or languages). Translation is a large part of it, but there are other aspects, like date formatting, for example.
There is no single standard way to do internationalization. In this article we’ll learn the approach I chose, but there are other ways to achieve a similar result.
URLs
To make an internationalized app SEO friendly, it’s recommended to have locale-prefixed URLs. This means, if we have a dashboard
page, the URL for it will be something like: /<lang>/dashboard
.
This, of course, leaves the possibility of someone visiting our pages without a prefix, for example: /dashboard
. In this scenario, we will use locale detection to redirect users to the correct page for their language.