svelte-dialect
Tiny MessageFormat 2 i18n for Svelte 5 and SvelteKit.
Runes instead of stores, namespaced keys, SSR locale negotiation, URL routing and typed message keys — in a library small enough to read in one sitting. This site is also the demo: it runs on the exact setup described here, prefix and all.
Built on MessageFormat 2 — rich text lands as snippets, not string concatenation
Quickstart #
The core of it: create the dialect once and wire two hooks. The full path, from install to the first translated line, is on the Setup page.
import { createDialect } from 'svelte-dialect/kit';
export const { t, handle, reroute, localizeHref, locales } = createDialect({
messages: import.meta.glob('./messages/**/*.json', { eager: true }),
defaultLocale: 'en',
routing: true
});import type { Handle } from '@sveltejs/kit/hooks';
import { handle as dialect } from '#lib/i18n.js';
export const handle: Handle = dialect;import type { Reroute } from '@sveltejs/kit/hooks';
import { reroute as dialect } from '#lib/i18n.js';
export const reroute: Reroute = dialect;Try it #
Hello, Svelte!
You clicked 0 times
Plural categories come from the locale, not from the library. Switch to Russian and the same message picks one / few / many.
Where to go next #
Setup
Install the package and wire it up, step by step, until the first translated line renders.
Read moreMessage files
Namespaced keys, plurals, numbers and dates, and what happens when a translation is missing or broken.
Read moreLocale in the URL
/some/url for the default locale, /ru/some/url for everything else — cookie-remembered, prefix-overridable, the setup this site runs.
Read more