es-fluent 0.21.1

Type-safe Fluent localization derives and runtime traits for Rust applications
Documentation

es-fluent

Codecov: es-fluent crates.io: es-fluent

The public facade for typed Project Fluent messages in Rust. Applications depend on this crate for message derives and runtime traits, then choose an embedded, Dioxus, or Bevy manager to resolve translations.

Requires Rust 1.99 or newer. Configured message-owning packages provide i18n.toml, fallback FTL, and a build script using es-fluent-build for compile-time fallback validation.

Features

The default feature set enables derive.

Feature Default Purpose
derive Yes Re-exports EsFluent, EsFluentChoice, EsFluentLabel, and EsFluentVariants.
debug-embed No Enables embedded manager-core assets and embeds them in native debug builds.
icu-datetime No Formats SystemTime and Duration arguments with ICU4X in the active locale.
chrono No Enables icu-datetime and Chrono temporal arguments.
jiff No Enables icu-datetime and Jiff temporal arguments.

Example

This declaration is an excerpt from the maintained example library and uses the default derive feature. Its package supplies the locale configuration, fallback catalog, and embedded module registration.

use es_fluent::EsFluent;

#[derive(EsFluent)]
pub struct WelcomeMessage<'a> {
    pub name: &'a str,
    pub count: i32,
}

The CLI discovers the library target and derives this fallback message and its arguments; translators edit the FTL value:

welcome_message = Welcome Message { $name } { $count }

With i18n initialized for English, the complete executable passes a borrowed message to i18n.localize_message(&welcome) and renders “Welcome Message John 5”.

EsFluentVariants supplies field or variant messages, EsFluentLabel supplies a type label, and EsFluentChoice supplies selector values.

Missing-message policy

The default strict policy checks derived messages against the fallback catalog at compile time. A package can select missing_message_policy = "fallback-str" in its i18n.toml to return snake_case Rust source names after locale fallback is exhausted. The generated keys carry their package's policy, so both policies can coexist. Fallible try_localize_message and try_localize_label still return None for missing output.