actix_cloud

Macro t

Source
macro_rules! t {
    ($l:expr, $key:expr) => { ... };
    ($l:expr, $key:expr, $($var_name:tt = $var_val:expr),+) => { ... };
    ($l:expr, $key:expr, $locale:expr) => { ... };
    ($l:expr, $key:expr, $locale:expr, $($var_name:tt = $var_val:expr),+) => { ... };
}
Available on crate feature i18n only.
Expand description

Get I18n text

use actix_cloud::{i18n::{i18n, Locale},t};

let mut locale = Locale::new("en-US").add_locale(i18n!("locale"));

// Get default locale's text
t!(locale, "greeting");
// With variables
t!(locale, "messages.hello", name = "Jason");
// Get a special locale's text
t!(locale, "greeting", "de");
// With locale and variables
t!(locale, "messages.hello", "de", name = "Jason");