Struct i18nx::Dictionary
source · pub struct Dictionary {
pub locale: Option<&'static str>,
pub resource: HashMap<&'static str, HashMap<&'static str, &'static str>>,
}
Expand description
Dictionary holds current locale and a map of translations for each locale.
Example:
use i18nx::Dictionary;
let mut dict = Dictionary::from_ron(r#"{
"Hello {name}!": {
"de": "Hallo {name}!",
"fr": "Bonjour {name}!",
},
}"#).unwrap();
dict.locale = Some("fr");
assert_eq!(
dict.get("Hello {name}!").unwrap(),
"Bonjour {name}!"
);
Fields§
§locale: Option<&'static str>
Locale is a string that holds the current language.
resource: HashMap<&'static str, HashMap<&'static str, &'static str>>
The resource is a HashMap of translations, where the key is the message and the value is a HashMap of translations for each locale.
Implementations§
Trait Implementations§
source§impl Debug for Dictionary
impl Debug for Dictionary
source§impl Default for Dictionary
impl Default for Dictionary
source§fn default() -> Dictionary
fn default() -> Dictionary
Returns the “default value” for a type. Read more