Skip to main content

t

Macro t 

Source
macro_rules! t {
    ($key:expr) => { ... };
    ($key:expr, $locale:expr) => { ... };
    ($key:expr, fallback: $fallback:expr) => { ... };
    ($key:expr, $locale:expr, fallback: $fallback:expr) => { ... };
}
Expand description

Translates a key using the active locale.

Falls back through the fallback chain and finally returns the key itself if no translation is found anywhere.

ยงExamples

use lang_lib::t;

// Active locale
let msg = t!("greeting");

// Specific locale
let msg = t!("greeting", "es");

// Inline fallback
let msg = t!("unknown_key", fallback: "Hello");