i18n-js

The preset for i18n-js. It reads I18n.t and i18n.t calls and %{name} placeholders.

The i18n-js preset supports i18n-js, the JS companion of Rails I18n.

Detection

The preset applies when the project depends on i18n-js.

x18n.config.ts
import { i18nJs } from '@x18n/cli/presets'
import { defineConfig } from '@x18n/core'

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

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

I18n.t and i18n.t are translate calls:

src/a.js
I18n.t('a.b')

Placeholders

Percent braces: %{name}.

Extraction templates

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