Skip to main content

Crate ferro_lang

Crate ferro_lang 

Source
Expand description

§Ferro Lang

Localization for the Ferro web framework.

Provides JSON-based translation loading, :param interpolation, pipe-separated pluralization, and locale fallback chains.

§Example

use ferro_lang::Translator;

// Load translations from lang/ directory with "en" as fallback
let translator = Translator::load("lang", "en").unwrap();

// Simple translation with parameter interpolation
let msg = translator.get("en", "welcome", &[("name", "Alice")]);
assert_eq!(msg, "Welcome, Alice!");

// Pluralized translation
let msg = translator.choice("en", "items.count", 5, &[]);
assert_eq!(msg, "5 items");

Re-exports§

pub use config::LangConfig;
pub use config::LangConfigBuilder;

Modules§

config

Structs§

Translator
Core translation engine.

Enums§

LangError
Errors that can occur during translation loading and lookup.

Functions§

normalize_locale
Normalize a locale identifier to lowercase with hyphens.