---
title: "polyglot"
description: "The preset for Polyglot.js. It reads polyglot.t calls and %{name} placeholders."
canonical_url: "https://x18n.dev/presets/polyglot"
---
# polyglot

> The preset for Polyglot.js. It reads polyglot.t calls and %\{name} placeholders.

The `polyglot` preset supports [Polyglot.js](https://airbnb.io/polyglot.js) by Airbnb.

## Detection

The preset applies when the project depends on `node-polyglot`.

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

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

## Locale files

The preset adds no resource patterns. Set `resources` in the config, or let x18n guess the locale directories. For example, x18n finds `translations/en.json` without a config.

## Supported syntax

`polyglot.t` and `I18n.t` are translate calls in JS and TS:

```js [src/a.js]
polyglot.t('a.b')
```

In Ruby files, the preset reads the same two calls with a regex.

## Placeholders

Percent braces: `%{name}`.

## Extraction templates

| Kinds                      | Template                    |
| -------------------------- | --------------------------- |
| `js-string`, `js-template` | `polyglot.t('{key}'{args})` |


## Sitemap

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