Skip to main content
Version: 5.x.x

Migrating to v5 (Svelte)

In version 5, the core library was completely redesigned. Before you start, please read the general info about this new version.

Update TolgeeProvider component and initialize Tolgee as described in core migration:

const tolgee = ...

...

<TolgeeProvider tolgee={tolgee}>
<div slot="fallback">Loading...</div>
<Children/>
</TolgeeProvider>

Changing language

We've removed v4 getLanguageStore, it's now replaced by the more general hook getTolgee (read more).

<script>
import { getTolgee } from '@tolgee/svelte';

const tolgee = getTolgee(['language'])

function handleLanguageChange(e) {
$tolgee.changeLanguage(e.currentTarget.value)
}
</script>

<select value={$tolgee.getLanguage()} on:change={handleLanguageChange}>
...
</select>

Translating

useTranslate now returns an object with t store instead of the t directly.

const { t } = useTranslate();

...

$t('key')