Archived
45 lines
1.3 KiB
Rust
45 lines
1.3 KiB
Rust
//! el-i18n — Localization for el-ui.
|
|
//!
|
|
//! RTL-aware, plural forms, CLDR-based number/currency formatting.
|
|
//!
|
|
//! ## Quick start
|
|
//!
|
|
//! ```
|
|
//! use el_i18n::prelude::*;
|
|
//! use std::collections::HashMap;
|
|
//!
|
|
//! // Build a bundle
|
|
//! let mut bundle = LocaleBundle::new(Locale::en_us());
|
|
//! bundle.insert("profile.follow", "Follow");
|
|
//! let mut forms = HashMap::new();
|
|
//! forms.insert("one".to_string(), "{n} Follower".to_string());
|
|
//! forms.insert("other".to_string(), "{n} Followers".to_string());
|
|
//! bundle.insert_plural("profile.followers", forms);
|
|
//!
|
|
//! // Create a context
|
|
//! let ctx = LocaleContext::new(Locale::en_us(), bundle);
|
|
//!
|
|
//! // Translate
|
|
//! assert_eq!(ctx.t("profile.follow"), "Follow");
|
|
//! assert_eq!(ctx.t_plural("profile.followers", 1), "1 Follower");
|
|
//! assert_eq!(ctx.t_plural("profile.followers", 42), "42 Followers");
|
|
//! ```
|
|
|
|
#![deny(warnings)]
|
|
|
|
pub mod bundle;
|
|
pub mod format;
|
|
pub mod locale;
|
|
pub mod plural;
|
|
pub mod t;
|
|
|
|
pub mod prelude {
|
|
pub use crate::bundle::{load_toml, LocaleBundle, TranslationValue};
|
|
pub use crate::format::{format_currency, format_integer, format_number, format_percent};
|
|
pub use crate::locale::{Locale, TextDirection};
|
|
pub use crate::plural::{plural_form, PluralForm};
|
|
pub use crate::t::LocaleContext;
|
|
}
|
|
|
|
pub use prelude::*;
|