es-fluent-manager-embedded

Crates.ioes-fluent-manager-embedded
lib.rses-fluent-manager-embedded
version0.6.0
created_at2025-10-12 21:21:09.86918+00
updated_at2026-01-16 12:04:00.790624+00
descriptiones-fluent manager for rust_embed
homepage
repositoryhttps://github.com/stayhydated/es-fluent
max_upload_size
id1879734
size30,597
stayhydated (stayhydated)

documentation

README

Docs Crates.io

es-fluent-manager-embedded

A zero-setup, global localization manager for es-fluent.

This crate provides a "Just Works" experience for adding localization to standard Rust applications (CLIs, TUIs, desktop apps). It bundles your translations directly into the binary and provides a global singleton for access.

Features

  • Embedded Assets: Compiles your FTL files into the binary (using rust-embed under the hood).
  • Global Access: Once initialized, you can call `to_fluent_string() anywhere in your code without passing context around.
  • Thread Safe: Uses OnceLock and atomic swaps for safe concurrent access.

Quick Start

1. Define the Module

In your crate root (lib.rs or main.rs), tell the manager to scan your assets:

// a i18n.toml file must exist in the root of the crate
es_fluent_manager_embedded::define_embedded_i18n_module!();

2. Initialize & Use

In your application entry point:

use es_fluent::ToFluentString;
use unic_langid::langid;

fn main() {
    // 1. Initialize the global manager
    es_fluent_manager_embedded::init();

    // 2. Set the language (e.g., from system locale or user config)
    es_fluent_manager_embedded::select_language(&langid!("en-US"));

    // 3. Localize things!
    let msg = MyMessage::Hello { name: "World" };
    println!("{}", msg.to_fluent_string());
}

When to use

  • Use this if: You are building a standalone app and want simplicity.
  • Don't use this if: You are using Bevy (use es-fluent-manager-bevy) or need strictly decoupled, dependency-injected managers.
Commit count: 444

cargo fmt