FluentBundle
Immutable runtime bundle for localizing messages.
A FluentBundle holds messages, terms, and functions for a specific locale, plus the configuration needed to format them. Construct one through FluentBundleBuilder (or the fluentBundle DSL) — the public constructor is internal so bundles are guaranteed immutable by construction.
Basic usage
val bundle = fluentBundle(locales = listOf(LanguageIdentifier.parse("en-US"))) {
resource("hello = Hello, { $name }!")
builtins()
}
val output = bundle.format("hello", fluentArgsOf("name" to "World"))After build returns, every method on this class is safe to call from multiple threads simultaneously. The internal state is populated once and never mutated.
Properties
Functions
Alias for formatMessage.
Format a specific attribute of a message by ID.
Format a message by its ID, resolving all references.
Format a message and return both the result and any errors collected during resolution. Returns (null, [...]) for a missing message id and (null, []) for an empty-value message; otherwise (text, errors).
Format a pattern directly.
Look up a custom function by name.
Look up a message by its ID.
Look up a term by its ID.
The transform function passed at build time, or null if none.
Check if a custom function is registered.
Check if a message exists.
Get the memoizer for caching formatted values.