---
title: "Presets"
description: "The built-in presets, how x18n detects them, and the placeholders and extraction templates they add."
canonical_url: "https://x18n.dev/presets"
---
# Presets

> The built-in presets, how x18n detects them, and the placeholders and extraction templates they add.

A preset is a group of plugins for one i18n library. It tells x18n which calls are translate calls, how namespaces work, which placeholder syntax the messages use, and which code replaces a hard string.

## Built-in presets

<!-- generated:preset-groups -->

`general` applies to every project, after the others:

| Preset                                        | Library | Detected from |
| --------------------------------------------- | ------- | ------------- |
| [`general`](https://x18n.dev/presets/general) | none    | always        |

### :x18n-icon{name="i-logos-vue"} Vue

| Preset                                                          | Library          | Detected from                                                                        |
| --------------------------------------------------------------- | ---------------- | ------------------------------------------------------------------------------------ |
| [`vue-i18n`](https://x18n.dev/presets/vue-i18n)                 | vue-i18n         | `vue-i18n`, `vuex-i18n`, `petite-vue-i18n`, `vue-i18n-bridge`, `@intlify/*`          |
| [`fluent-vue`](https://x18n.dev/presets/fluent-vue)             | fluent-vue       | `fluent-vue`, `fluent-vue-loader`, `rollup-plugin-fluent-vue`, `unplugin-fluent-vue` |
| [`laravel-vue-i18n`](https://x18n.dev/presets/laravel-vue-i18n) | laravel-vue-i18n | `laravel-vue-i18n`                                                                   |

### :x18n-icon{name="i-logos-nuxt-icon"} Nuxt

| Preset                                                        | Library         | Detected from               |
| ------------------------------------------------------------- | --------------- | --------------------------- |
| [`nuxt-i18n`](https://x18n.dev/presets/nuxt-i18n)             | @nuxtjs/i18n    | `@nuxtjs/i18n`, `nuxt-i18n` |
| [`nuxt-i18n-micro`](https://x18n.dev/presets/nuxt-i18n-micro) | Nuxt I18n Micro | `nuxt-i18n-micro`           |

### :x18n-icon{name="i-logos-react"} React

| Preset                                                        | Library               | Detected from                                    |
| ------------------------------------------------------------- | --------------------- | ------------------------------------------------ |
| [`i18next`](https://x18n.dev/presets/i18next)                 | i18next               | `i18next`                                        |
| [`react-i18next`](https://x18n.dev/presets/react-i18next)     | react-i18next         | `react-i18next`, `next-i18next`                  |
| [`i18next-shopify`](https://x18n.dev/presets/i18next-shopify) | i18next-shopify       | `@shopify/i18next-shopify`                       |
| [`react-intl`](https://x18n.dev/presets/react-intl)           | react-intl (FormatJS) | `react-intl`, `@formatjs/*`                      |
| [`lingui`](https://x18n.dev/presets/lingui)                   | Lingui                | `@lingui/core`, `@lingui/react`, `@lingui/macro` |
| [`fluent-react`](https://x18n.dev/presets/fluent-react)       | @fluent/react         | `@fluent/react`                                  |

### :x18n-icon{name="i-simple-icons-nextdotjs"} Next.js

| Preset                                                              | Library            | Detected from           |
| ------------------------------------------------------------------- | ------------------ | ----------------------- |
| [`next-intl`](https://x18n.dev/presets/next-intl)                   | next-intl          | `next-intl`, `use-intl` |
| [`next-translate`](https://x18n.dev/presets/next-translate)         | next-translate     | `next-translate`        |
| [`next-international`](https://x18n.dev/presets/next-international) | next-international | `next-international`    |

### :x18n-icon{name="i-logos-angular-icon"} Angular

| Preset                                                          | Library           | Detected from                                              |
| --------------------------------------------------------------- | ----------------- | ---------------------------------------------------------- |
| [`angular-localize`](https://x18n.dev/presets/angular-localize) | @angular/localize | `@angular/localize` with an `i18n` block in `angular.json` |
| [`ngx-translate`](https://x18n.dev/presets/ngx-translate)       | ngx-translate     | `@ngx-translate/core`                                      |
| [`transloco`](https://x18n.dev/presets/transloco)               | Transloco         | `@jsverse/transloco`, `@ngneat/transloco`                  |
| [`angular-i18next`](https://x18n.dev/presets/angular-i18next)   | angular-i18next   | `angular-i18next`                                          |

### :x18n-icon{name="i-logos-svelte-icon"} Svelte

| Preset                                                      | Library                     | Detected from                                           |
| ----------------------------------------------------------- | --------------------------- | ------------------------------------------------------- |
| [`svelte-i18n`](https://x18n.dev/presets/svelte-i18n)       | svelte-i18n, sveltekit-i18n | `svelte-i18n`, `sveltekit-i18n`, `@sveltekit-i18n/base` |
| [`svelte-i18next`](https://x18n.dev/presets/svelte-i18next) | svelte-i18next              | `svelte-i18next`                                        |

### :x18n-icon{name="i-logos-javascript"} Other JavaScript

| Preset                                                                    | Library                | Detected from                                                                                                                        |
| ------------------------------------------------------------------------- | ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------ |
| [`paraglide`](https://x18n.dev/presets/paraglide)                         | Paraglide JS           | `@inlang/paraglide-js`, `@inlang/paraglide-sveltekit`, `@inlang/paraglide-next`, `@inlang/paraglide-astro`, `@inlang/paraglide-vite` |
| [`solid-primitives-i18n`](https://x18n.dev/presets/solid-primitives-i18n) | @solid-primitives/i18n | `@solid-primitives/i18n`                                                                                                             |
| [`lit-localize`](https://x18n.dev/presets/lit-localize)                   | `@lit/localize`        | `@lit/localize`                                                                                                                      |
| [`typesafe-i18n`](https://x18n.dev/presets/typesafe-i18n)                 | typesafe-i18n          | `typesafe-i18n`                                                                                                                      |
| [`gravity-ui-i18n`](https://x18n.dev/presets/gravity-ui-i18n)             | @gravity-ui/i18n       | `@gravity-ui/i18n`                                                                                                                   |
| [`adonisjs`](https://x18n.dev/presets/adonisjs)                           | AdonisJS i18n          | `@adonisjs/i18n`                                                                                                                     |
| [`ember-intl`](https://x18n.dev/presets/ember-intl)                       | ember-intl             | `ember-intl`                                                                                                                         |
| [`polyglot`](https://x18n.dev/presets/polyglot)                           | Polyglot.js            | `node-polyglot`                                                                                                                      |
| [`globalize`](https://x18n.dev/presets/globalize)                         | Globalize              | `globalize`                                                                                                                          |
| [`i18n-tag`](https://x18n.dev/presets/i18n-tag)                           | es2015-i18n-tag        | `es2015-i18n-tag`                                                                                                                    |
| [`ruby-i18n-js`](https://x18n.dev/presets/ruby-i18n-js)                   | i18n-js                | `i18n-js`                                                                                                                            |
| [`ui5`](https://x18n.dev/presets/ui5)                                     | SAPUI5, OpenUI5        | `@ui5/cli`                                                                                                                           |

### :x18n-icon{name="i-ph-puzzle-piece-duotone"} Extensions

| Preset                                                          | Library                      | Detected from                                                                      |
| --------------------------------------------------------------- | ---------------------------- | ---------------------------------------------------------------------------------- |
| [`chrome-extension`](https://x18n.dev/presets/chrome-extension) | Chrome and WebExtension i18n | `default_locale` in `manifest.json`, `src/manifest.json` or `public/manifest.json` |
| [`vscode-extension`](https://x18n.dev/presets/vscode-extension) | VS Code extension API        | `vscode`, `@types/vscode`                                                          |

### :x18n-icon{name="i-ph-device-mobile-duotone"} Mobile

| Preset                                                            | Library                  | Detected from                           |
| ----------------------------------------------------------------- | ------------------------ | --------------------------------------- |
| [`flutter`](https://x18n.dev/presets/flutter)                     | flutter_i18n             | `flutter_i18n` in `pubspec.yaml`        |
| [`easy-localization`](https://x18n.dev/presets/easy-localization) | easy_localization        | `easy_localization` in `pubspec.yaml`   |
| [`flutter-translate`](https://x18n.dev/presets/flutter-translate) | flutter_translate        | `flutter_translate` in `pubspec.yaml`   |
| [`android-strings`](https://x18n.dev/presets/android-strings)     | Android string resources | `AndroidManifest.xml` with `res/values` |

### :x18n-icon{name="i-logos-php"} PHP

| Preset                                                | Library        | Detected from                                         |
| ----------------------------------------------------- | -------------- | ----------------------------------------------------- |
| [`laravel`](https://x18n.dev/presets/laravel)         | Laravel        | `laravel/framework` in `composer.json`                |
| [`php-joomla`](https://x18n.dev/presets/php-joomla)   | Joomla         | `joomla/application`, `joomla/cms` in `composer.json` |
| [`php-gettext`](https://x18n.dev/presets/php-gettext) | gettext in PHP | never: list it in `presets`                           |

### :x18n-icon{name="i-logos-ruby"} Ruby

| Preset                                              | Library                          | Detected from                                   |
| --------------------------------------------------- | -------------------------------- | ----------------------------------------------- |
| [`ruby-rails`](https://x18n.dev/presets/ruby-rails) | Ruby on Rails                    | `rails`, `rails-i18n`, `railties` in `Gemfile`  |
| [`jekyll`](https://x18n.dev/presets/jekyll)         | jekyll-multiple-languages-plugin | `jekyll-multiple-languages-plugin` in `Gemfile` |

### :x18n-icon{name="i-logos-python"} Python

| Preset                                                      | Library                                       | Detected from                                                      |
| ----------------------------------------------------------- | --------------------------------------------- | ------------------------------------------------------------------ |
| [`python-gettext`](https://x18n.dev/presets/python-gettext) | gettext in Python: Django, Flask-Babel, Babel | `django`, `flask-babel` in `pyproject.toml` or `requirements.txt`  |
| [`i18nice`](https://x18n.dev/presets/i18nice)               | i18nice, python-i18n                          | `i18nice`, `python-i18n` in `pyproject.toml` or `requirements.txt` |

### :x18n-icon{name="i-ph-terminal-window-duotone"} Rust and .NET

| Preset                                                | Library                                       | Detected from                                              |
| ----------------------------------------------------- | --------------------------------------------- | ---------------------------------------------------------- |
| [`cargo-i18n`](https://x18n.dev/presets/cargo-i18n)   | cargo-i18n (Fluent)                           | `i18n-embed-fl`, `i18n-embed` in `Cargo.toml`              |
| [`dotnet-resx`](https://x18n.dev/presets/dotnet-resx) | .NET `IStringLocalizer` and `.resx` resources | a `*.csproj`, `*.vbproj` or `*.fsproj` and a `*.resx` file |

<!-- /generated:preset-groups -->

## Detection

With the default `presets: 'auto'`, x18n tests each preset in the order of the table. Most presets apply when the project depends on one of the listed packages. x18n reads the dependencies, dev dependencies and peer dependencies in `package.json`, the dependencies in `composer.json`, `pubspec.yaml`, `Gemfile` and `Cargo.toml`, and the Python requirements in `pyproject.toml` (`[project]`, `[project.optional-dependencies]`, `[dependency-groups]` and the Poetry dependency tables) and `requirements.txt`. Python package names compare in their normalized form, so `Flask_Babel` is `flask-babel`. The manifests in the parent directories, up to the git root, count too.

More than one preset can apply. Some presets include the plugins of another preset: `react-i18next` and `svelte-i18next` include everything of `i18next`, and `i18next-shopify` includes everything of `react-i18next`. When two applied presets share a plugin, x18n adds that plugin one time.

A preset can be exclusive. When an exclusive preset applies, x18n tests no preset after it. `laravel` and `php-gettext` are exclusive. `php-gettext` has no detection, so it applies only when you list it.

Run `x18n doctor` to see the result. Each preset shows as `detected`, `not-detected`, `listed`, or `after-exclusive`.

## List presets

To pick the presets yourself, list them. x18n then applies exactly the listed presets and detects none:

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

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

```yaml [x18n.config.yml]
presets: [vue-i18n, general]
```
::

The names are those in the first column of the table, in every config format. `presets: []` turns every preset off.

In TS, each preset is also a function in `@x18n/builtins/presets/<name>`, named in camelCase. Use it when a config builds on the preset object:

```ts [x18n.config.ts]
import { vueI18n } from '@x18n/builtins/presets/vue-i18n'
import { defineConfig } from '@x18n/core'

export default defineConfig({
  presets: [
    vueI18n()
  ],
})
```

## What a preset adds

Each preset page lists what the preset adds:

- Translate calls: the callee names that count as translate calls, and where the key, the namespace and the key prefix come from. These become `usage.calls`.
- Defaults: namespace rules, derived keys and resource patterns.
- Placeholders: the syntax of the placeholders in messages.
- Extraction templates: the code that replaces a hard string.

Your config adds to these defaults. For example, `usage.calls` in the config adds callees to the ones of the preset. See [How x18n merges the config](https://x18n.dev/guide/configuration#how-x18n-merges-the-config).

## Resource defaults

The resource patterns of all applied presets add up. For example, a project with `next-intl` and `ngx-translate` uses the patterns of both presets.

- If your config has `resources`, x18n uses only your patterns. They replace the patterns of every preset.
- If the patterns of the presets match no file, x18n guesses the locale directories, as it does without presets. See [Locale files](https://x18n.dev/guide/configuration#locale-files).
- A pattern without `{locale}`, such as `webapp/i18n/i18n.properties`, holds the source locale. To give it another locale, set `locale` on the resource.

## Placeholders

A placeholder syntax tells x18n how placeholders look in messages. The [`placeholder-mismatch`](https://x18n.dev/checks/placeholder-mismatch) check and `x18n apply` compare the placeholders of each translation with the source value. Translate prompts list them.

| Syntax            | Example                                                   | Used by                                                                                                                                         |
| ----------------- | --------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- |
| braces            | `{name}`, `{0}`                                           | vue-i18n, nuxt-i18n, nuxt-i18n-micro, i18next-shopify, next-international, ui5, vscode-extension, flutter, easy-localization, flutter-translate |
| positional braces | `{}`                                                      | easy-localization                                                                                                                               |
| linked            | `@:key`, `@.lower:key`                                    | vue-i18n, nuxt-i18n, easy-localization                                                                                                          |
| typed braces      | `{name}`, `{name:string}`, `{date\|weekday}`              | typesafe-i18n                                                                                                                                   |
| double braces     | `{{name}}`, `{{name, format}}`, `{{- raw}}`               | i18next, react-i18next, i18next-shopify, next-translate, gravity-ui-i18n, ngx-translate, transloco, flutter-translate                           |
| nesting           | `$t(key)`                                                 | i18next, react-i18next, angular-i18next, i18next-shopify                                                                                        |
| ICU               | `{name}`, `{count, plural, one {# item} other {# items}}` | next-intl, react-intl, svelte-i18n, lingui, ember-intl, globalize                                                                               |
| fluent            | `{ $name }`                                               | fluent-vue, fluent-react                                                                                                                        |
| percent braces    | `%{name}`                                                 | polyglot, ruby-i18n-js, ruby-rails, i18nice                                                                                                     |
| printf            | `%s`, `%d`, `%1$s`                                        | php-joomla, php-gettext                                                                                                                         |
| Python percent    | `%(name)s`, `%s`, `%d`                                    | python-gettext                                                                                                                                  |
| colon             | `:name`                                                   | laravel                                                                                                                                         |
| dollars           | `$name$`                                                  | chrome-extension                                                                                                                                |
| dotnet            | `{0}`, `{0:C}`, `{0,-10}`, `{name}`                       | dotnet-resx                                                                                                                                     |
| angular           | `{$INTERPOLATION}`, `{$START_LINK}`                       | angular-localize                                                                                                                                |

A linked message (`@:key`) and a nesting placeholder (`$t(key)`) name another key. That key then counts as used. The [`invalid-syntax`](https://x18n.dev/checks/invalid-syntax) check reports a linked message whose key does not exist, and ICU messages that do not parse or that lack an `other` case.

Plugins can use all of these syntaxes from `@x18n/builtins/placeholders`. A [YAML plugin](https://x18n.dev/plugins/yaml#placeholders) can declare a shape such as `%{name}`.

## Extraction templates

`x18n extract` replaces a hard string with code from a template. A template has these tokens:

| Token      | Becomes                                                                                                                                                                                                |
| ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `{key}`    | The new key.                                                                                                                                                                                           |
| `{attr}`   | The attribute name, for attribute kinds.                                                                                                                                                               |
| `{args}`   | The arguments of a template string: `, { name: user.name }`, without the `, ` right after `(`. Empty when there are none.                                                                              |
| `{text}`   | The message of the hard string, as stored in the source locale: the original text, with the arguments of a template string as placeholders. Use it for a default value, as in `$t('{key}', '{text}')`. |
| `{source}` | The text of the hard string as written in the file, unchanged. Use it for markup that keeps the source around it.                                                                                      |
| `{parts}`  | The message as the body of a template string, each argument as `${expression}:NAME:`, as `$localize` writes it.                                                                                        |

x18n escapes `{key}` and `{text}` for the quotes around them. Inside `'...'` or `"..."` it escapes backslashes, that quote and line breaks. Inside a template literal it escapes backslashes, backticks and `${`. Inside a quoted attribute, such as `:title="$t('{key}', '{text}')"`, it also writes `&` and the attribute quote as entities. Outside quotes the value goes in as is.

Each hard string has a kind, which tells where it is:

| Kind                                                   | Example                                                                                                                                   |
| ------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------- |
| `jsx-text`                                             | `<p>Hello</p>` in JSX                                                                                                                     |
| `jsx-attribute`                                        | `<input placeholder="Search" />` in JSX                                                                                                   |
| `vue-template-text`                                    | Text in a Vue template                                                                                                                    |
| `vue-attribute`                                        | An attribute in a Vue template                                                                                                            |
| `svelte-text`                                          | Text in a Svelte component                                                                                                                |
| `svelte-attribute`                                     | An attribute in a Svelte component                                                                                                        |
| `astro-text`                                           | Text in an Astro template                                                                                                                 |
| `astro-attribute`                                      | An attribute in an Astro template                                                                                                         |
| `html-text`                                            | Text in an HTML or Angular template (`ngx-translate`, `transloco`, `angular-i18next`), or with no element of its own (`angular-localize`) |
| `html-element`                                         | An Angular element with text, marked with `i18n` as one message (`angular-localize`)                                                      |
| `html-attribute`                                       | An attribute in an HTML or Angular template                                                                                               |
| `dq-html-text`, `dq-html-element`, `dq-html-attribute` | The same in an inline Angular `template:` in double quotes, which takes `i18n='...'` (`angular-localize`)                                 |
| `js-string`                                            | A string literal in JS or TS                                                                                                              |
| `js-template`                                          | A template string in JS or TS                                                                                                             |

x18n picks the first template that matches the kind (`kinds`) and the file (`files`). It tries the templates of `extract.templates` first, then those of the presets, then these defaults:

| Kinds                              | Template                      |
| ---------------------------------- | ----------------------------- |
| `jsx-text`, `astro-text`           | `{t('{key}'{args})}`          |
| `jsx-attribute`, `astro-attribute` | `{attr}={t('{key}'{args})}`   |
| `vue-template-text`, `html-text`   | `{{ $t('{key}'{args}) }}`     |
| `vue-attribute`, `html-attribute`  | `:{attr}="$t('{key}'{args})"` |
| `svelte-text`                      | `{$t('{key}'{args})}`         |
| `svelte-attribute`                 | `{attr}={$t('{key}'{args})}`  |
| any                                | `t('{key}'{args})`            |

A template can add `imports`: lines that x18n adds once to the file when they are missing, such as `import { useI18n } from 'vue-i18n'`.

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

export default defineConfig({
  extract: {
    keyPrefix: '{component}',
    templates: [
      {
        template: 'i18n.t(\'{key}\'{args})',
        kinds: ['js-string', 'js-template'],
        files: ['src/server/**'],
        imports: ['import { i18n } from \'~/i18n\''],
      },
    ],
  },
})
```


## Sitemap

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