---
title: "svelte-i18n"
description: "The preset for svelte-i18n. It reads the $_ store and its aliases in Svelte components and scripts."
canonical_url: "https://x18n.dev/presets/svelte-i18n"
---
# svelte-i18n

> The preset for svelte-i18n. It reads the $\_ store and its aliases in Svelte components and scripts.

The `svelte-i18n` preset supports [svelte-i18n](https://github.com/kaisermann/svelte-i18n) and [sveltekit-i18n](https://github.com/sveltekit-i18n/lib).

## Detection

The preset applies when the project depends on `svelte-i18n`, `sveltekit-i18n` or `@sveltekit-i18n/base`.

```ts [x18n.config.ts]
import { defineConfig } from '@x18n/core'

export default defineConfig({
  presets: ['svelte-i18n'],
})
```

## Supported syntax

These names count as translate calls: `$_`, `$t`, `$format`, `_`, `t`, `format`, `$json` and `json`.

<!-- eslint-skip -->

```svelte [src/App.svelte]
<script>
  import { _ } from 'svelte-i18n'
</script>

<h1>{$_('app.title')}</h1>
<p>{$_('app.greeting', { values: { name: 'Ada' } })}</p>
```

The Svelte scanner reads the `<script>` blocks and the template expressions of `.svelte` files. It runs in Node only.

## Placeholders

ICU MessageFormat, as for [next-intl](https://x18n.dev/presets/next-intl#placeholders).

## Extraction templates

| Kinds              | Template                     | Imports                           |
| ------------------ | ---------------------------- | --------------------------------- |
| `svelte-text`      | `{$_('{key}'{args})}`        | `import { _ } from 'svelte-i18n'` |
| `svelte-attribute` | `{attr}={$_('{key}'{args})}` | `import { _ } from 'svelte-i18n'` |


## Sitemap

See the full [sitemap](https://x18n.dev/sitemap.md) for all pages.
