Struct loon_embed::Dictionary[][src]

pub struct Dictionary { /* fields omitted */ }
Expand description

Container for translation messages

Implementations

Get the translated message.

key can be a dot-delimited &str or a &[&str] path.

opts can be an Opts object, None, or Var, Count, Locale, or DefaultKey (or up to a 4-tuple of these items).

Examples:

use loon::prelude::*;
let dict = Dictionary::default();
let _ = dict.translate("custom.greeting", Opts::default().var("name", "Jacob"));
let _ = dict.translate(&["custom", "greeting"], Var("name", "Jacob"));    
let _ = dict.translate("greeting", None);
let _ = dict.translate("greeting", (Locale("de"), (DefaultKey("missing.message"))));

Shortcut for translate.

key can be a dot-delimited &str or a &[&str] path.

opts can be an Opts object, None, or Var, Count, Locale, or DefaultKey (or up to a 4-tuple of these items).

Examples:

use loon::prelude::*;
let dict = Dictionary::default();
let _ = dict.t("custom.greeting", Opts::default().var("name", "Jacob"));
let _ = dict.t(&["custom", "greeting"], Var("name", "Jacob"));    
let _ = dict.t("greeting", None);
let _ = dict.t("greeting", (Locale("de"), (DefaultKey("missing.message"))));

Trait Implementations

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.