Skip to content
F fluenti

@fluenti/core

The framework-agnostic core engine. Zero runtime dependencies.

Create a Fluenti instance.

import { createFluent } from '@fluenti/core'
const i18n = createFluent({
locale: 'en',
fallbackLocale: 'en',
messages: {
en: { greeting: 'Hello {name}!' },
},
})
i18n.t('greeting', { name: 'World' }) // "Hello World!"
PropertyTypeDescription
localestringCurrent locale
fallbackLocalestring?Fallback locale
messagesAllMessagesLocale-to-messages map
missing(locale, id) => string?Missing message handler
dateFormatsDateFormatOptions?Named date format styles
numberFormatsNumberFormatOptions?Named number format styles
MethodDescription
t(id, values?)Translate a message
format(message, values?)Direct ICU interpolation without catalog lookup
d(value, style?)Format a date
n(value, style?)Format a number
tRaw(message, values?)@deprecated Use format() instead
setLocale(locale)Change active locale
loadMessages(locale, msgs)Add messages at runtime
getLocales()List available locales

Parse an ICU MessageFormat string into an AST.

import { parse } from '@fluenti/core'
const ast = parse('{count, plural, one {# item} other {# items}}')

Compile an AST into a CompiledMessage.

Parse, compile, and execute a message string in one call. Results are cached.

Tagged template for lazy message descriptors:

import { msg } from '@fluenti/core'
const desc = msg`Hello ${name}` // { id: 'abc123', message: 'Hello {0}' }
  • detectLocale(options) — Detect locale from request context
  • getSSRLocaleScript(locale) — Generate script tag for hydration
  • getHydratedLocale(fallback?) — Read locale on client