globalize

The preset for Globalize. It reads formatMessage and messageFormatter calls with paths such as greetings/hello.

The globalize preset supports Globalize.

Detection

The preset applies when the project depends on globalize.

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

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

Locale files

The preset adds no resource patterns. Set resources in the config, or let x18n guess the locale directories.

Supported syntax

These names count as translate calls: Globalize.formatMessage, Globalize.messageFormatter, globalize.formatMessage and globalize.messageFormatter.

Globalize separates the segments of a message path with a slash. The preset turns each slash into a dot, so this call is a usage of the key a.b:

src/a.js
Globalize.formatMessage('a/b')

Placeholders

ICU MessageFormat, as for next-intl.

Extraction templates

KindsTemplate
js-string, js-templateGlobalize.formatMessage('{key}'{args})