polyglot

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

The polyglot preset supports Polyglot.js by Airbnb.

Detection

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

x18n.config.ts
import { polyglot } from '@x18n/cli/presets'
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:

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

KindsTemplate
js-string, js-templatepolyglot.t('{key}'{args})