Localised Routing
Translated Paths
You can have different paths for each language with the pathnames option. Don't include the language or the base path.
/aboutfor English (default language)/de/uber-unsfor German/fr/a-proposfor French
By default the default language is located on your base path. Usually /. Unlike the other languages it does not have a language prefix.
This reflects the default prefixDefaultLanguage: "never" behavior.
If you want to also have a prefix for the default language, use the prefixDefaultLanguage: "always" option.
This does make it ambigous which language should be used on / so language negotiation will kick in.
Language Negotiation
Whenever the language cannot be determined from the URL alone the language negotiation is triggered. This happens in the following steps:
- Check if the
paraglide_langcookie is set from previous visits, if so, use it - Negotiate the language from the
Accept-Languageheader - Use the default language
After language negotiation you will be redirected to include the language in the URL.
Changing the default Language
Usually your default language is the same as the sourceLanguageTag of your Inlang Project, but it doesn't have to be.
You can change it by passing a defaultLanguageTag option to createI18n
Automatic Link Localisation
Paraglide-Sveltekit automatically translates links on your components using a preprocessor. This affects:
hrefattributes onatagsformactionattributes onbuttontagsactionattributes onforms
If you have other attributes that you want to be translated open an issue.
Link Translations
If you want a link to be translated into a specific language set the hreflang attribute.
Opt-out of translation by adding a data-no-translate attribute.
Programmatic Navigation with Translated Paths
SvelteKit's goto and redirect cannot be translated automatically. Localize the URLs you pass to them with i18n.resolveRoute().
Language Switchers
Language switchers are tricky because we need to dynamically translate the current URL path, which is itself translated. We need to get the untranslated version of the current path & translate it into the target language.
You can get the untranslated path using i18n.route()
Use this to create a language switcher.
Re-Loading Language-Dependent data
If you have a load function that returns data that depends on the language you can tell it to re-run on language changes by calling depends("paraglide:lang").
Paraglide-SvelteKit automatically calls invalidate("paraglide:lang") when the language changes.

