Expand description
vue-i18n’s t(), for components that call $t or useI18n().t: part of
ferrovue’s runtime.
§Example
use ferrovue::i18n::{Args, Locale, Message, Part, Value};
use ferrovue::I18n;
// What the compiler writes for `en.json`: `{ "greeting": "Hello {name}!" }`.
static LOCALES: &[Locale] = &[Locale::new(
"en",
&[("greeting", Message::new(&[&[Part::Text("Hello "), Part::Named("name"), Part::Text("!")]]))],
)];
let i18n = I18n::new(LOCALES, "en", &[]);
let args = Args::new().with_named(&[("name", Value::Str("Ada"))]);
assert_eq!(i18n.t("greeting", &args), "Hello Ada!");Structs§
- Args
- What a
t()call is given besides its key:t(key, { named }),t(key, [list]),t(key, plural), or a named object and a plural together. - I18n
- The messages and the locale one request renders in.
- Locale
- A locale’s messages, by key (nested keys joined with dots), sorted for lookup.
- Message
- A compiled message: one case, or the cases of a plural message (
one | many).