Choose an integration pattern for sveltekit-i18n
masterThe sveltekit-i18n library provides several integration patterns depending on your application's architecture and SEO requirements. Choose the one that matches your needs:
Routing & Architecture
- multi-page (Recommended): The most frequent use-case for applications with multiple routes. Translations are loaded based on locale and routes, preventing duplicate translation loads on both server and client.
- one-page: Best for single-page applications (SPAs). Translations are loaded dynamically according to the current locale.
- single-load: Loads all translations for all language mutations during initialization. Useful only if you require all translations to be immediately available.
- locale-param: A multi-page approach where language is determined by a URL parameter (e.g.,
https://example.com/?lang=en).
SEO & Adapter Optimization
- locale-router-static: Uses locale-based routing (e.g.,
/en/about). Optimized for@sveltejs/adapter-staticand great for SEO. - locale-router: Uses locale-based routing. Optimized for non-static adapters like
@sveltejs/adapter-node. - locale-router-advanced: Similar to
locale-routerbut optimized for non-static adapters where default locale routes do not have a language prefix in the path.
Component-Scoped Translations
- component-scoped-csr: Allows scoping translations to specific components. App translations load via SSR, but component translations are loaded via a component promise on the client side (CSR).
- component-scoped-ssr: Uses an exported
initmethod to initialize language mutations within the parent page'sloadmethod, delegating props back to the component instance.