How does SvelteKit handle internationalization (i18n)?
Answer
SvelteKit doesn't have built-in i18n but integrates well with libraries. Paraglide.js (by Inlang, built for SvelteKit): compile-time i18n with tree-shaken translations — each page only includes the strings it uses. Uses a messages/ folder with JSON locale files. No runtime overhead. svelte-i18n: runtime i18n with stores, plural forms, and date/number formatting. URL-based locale routing: the recommended pattern — prefix routes with locale: /en/about, /de/about. Implement in hooks.server.js: detect locale from URL, set in event.locals, make available to load functions. Redirect root / based on Accept-Language header. SvelteKit route groups: src/routes/[lang]/ with a layout that validates the locale param. Static prerendering: prerender each locale separately for maximum performance. export const prerender = true; export function entries() { return SUPPORTED_LOCALES.map(lang => ({ lang })); }.
Previous
What is the SvelteKit module system and $lib, $app imports?
Next
What are Svelte 5 snippets and how do they replace slots?
More Svelte / SvelteKit Questions
View all →- Advanced How does Svelte 5's reactivity model with $state differ from Svelte 4?
- Advanced What is SvelteKit's data loading waterfall problem and how do you solve it?
- Advanced How do you implement real-time features in SvelteKit?
- Advanced What is the SvelteKit shallow routing feature?
- Advanced How does SvelteKit handle static asset optimization?