| Crates.io | armature-i18n |
| lib.rs | armature-i18n |
| version | 0.1.2 |
| created_at | 2025-12-26 21:24:09.039224+00 |
| updated_at | 2025-12-30 22:20:22.019245+00 |
| description | Internationalization (i18n) support for Armature framework |
| homepage | https://pegasusheavy.github.io/armature |
| repository | https://github.com/pegasusheavy/armature |
| max_upload_size | |
| id | 2006293 |
| size | 139,093 |
Internationalization (i18n) support for the Armature framework.
[dependencies]
armature-i18n = "0.1"
use armature_i18n::{I18n, Locale};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let i18n = I18n::new()
.add_bundle("en", include_str!("locales/en.ftl"))
.add_bundle("es", include_str!("locales/es.ftl"));
// Simple translation
let msg = i18n.t("en", "hello")?;
// With arguments
let msg = i18n.t_args("en", "greeting", &[("name", "World")])?;
// Pluralization
let msg = i18n.t_plural("en", "items", 5)?;
Ok(())
}
# locales/en.ftl
hello = Hello!
greeting = Hello, { $name }!
items = { $count ->
[one] { $count } item
*[other] { $count } items
}
use armature_i18n::Locale;
// Parse Accept-Language header
let locales = Locale::from_accept_language("en-US,en;q=0.9,es;q=0.8");
// Negotiate best locale
let best = i18n.negotiate(&locales, &["en", "es", "fr"]);
MIT OR Apache-2.0