Expand description
§es-fluent
The public facade for typed
Project Fluent messages in Rust. It re-exports the
derive macros and runtime traits used by es-fluent manager
integrations.
§Add the facade
[dependencies]
es-fluent = "*"Derive a typed message in a library target:
use es_fluent::EsFluent;
#[derive(EsFluent)]
pub enum LoginMessage<'a> {
Welcome { name: &'a str },
SignedOut,
}The CLI generates message IDs and Fluent arguments from the type:
login_message-Welcome = Welcome, { $name }!
login_message-SignedOut = You are signed out.Resolve values through a concrete embedded, Dioxus, or Bevy manager:
let text = i18n.localize_message(&LoginMessage::Welcome { name: "Ada" });§Derive surface
EsFluentdefines messages and can infer selector values for unit-only enums.EsFluentVariantsgenerates localizable field or variant metadata.EsFluentLabeldefines a type-level label.EsFluentChoicedefines standalone selector values.
Features icu-datetime, chrono, and jiff
support localized temporal arguments for their matching types.
§Missing-message policy
Configured crates validate derived messages against the fallback locale during
compilation. Call es_fluent_build::track_i18n_assets() from Cargo’s selected
custom-build target so the compiler can read the generated fallback catalog. A
missing message value is a source-spanned compile-time error naming the Rust
item, domain, fallback root, and recovery command by default.
Set the package-local policy when the application must keep rendering after every locale and Fluent fallback is exhausted:
# i18n.toml
missing_message_policy = "fallback-str"strict is the default. Strict and fallback-string packages can coexist in the
same workspace build.
localize_message(...) and localize_label(...) then return the derived Rust
source name in snake_case. Struct messages and labels use the type name, enum
messages use the variant name, and EsFluentVariants messages use the source
field or variant name. Fallible try_localize_message(...) and
try_localize_label(...) continue to return None for missing output.
See the derive guide for attributes, generated FTL, domains, namespaces, choices, and labels. See the getting-started tutorial for CLI and runtime setup.
Structs§
- Fluent
Args - Generated Fluent arguments keyed by validated static argument names.
Traits§
- EsFluent
Choice - Converts an enum into a validated Fluent select variant key.
- Fluent
Label - A trait for types that have a Fluent label key representing the type itself.
- Fluent
Localizer - Runtime context that resolves Fluent message IDs for typed message values.
- Fluent
Localizer Ext - Public extension methods for generic explicit localization contexts.
- Fluent
Message - A typed Fluent message that can be resolved by an explicit localization backend.
Type Aliases§
- Fluent
Localizer Lookup - Fallible render-time lookup callback supplied by
super::FluentLocalizer. - Fluent
Message Lookup - Render-time lookup callback used by
super::FluentMessageimplementations.
Derive Macros§
- EsFluent
- Turns an enum or struct into a localizable message.
- EsFluent
Choice - Allows an enum to be used inside another message as a selector (e.g., for gender or status).
- EsFluent
Label - Generates a helper implementation of the
FluentLabeltrait and registers the type’s name as a key. - EsFluent
Variants - Generates variant enums for struct fields.