Skip to main content

t

Macro t 

Source
macro_rules! t {
    ($key:expr $(,)?) => { ... };
    ($key:expr, $($name:ident = $value:expr),+ $(,)?) => { ... };
}
Expand description

A Translation key with its params.

The short form of Translation::new(key).param(k, v)…, for attaching to an error with translate.

let err = ash_jsonapi::invalid_attribute!(ctx, "must be 80 or fewer", "name")
    .translate(ash_jsonapi::t!("todo.name.too_long", max = 80));

let meta = err.to_object().meta.unwrap();
assert_eq!(meta["i18n"]["key"], "todo.name.too_long");
assert_eq!(meta["i18n"]["params"]["max"], 80);