//! Translation for ommui-data items.
/// A translation trait.
pub trait XTr: std::fmt::Debug {
/// Translate a string.
fn xtr(&self, s: &str) -> String;
}
impl XTr for indexmap::IndexMap<String, String> {
fn xtr(&self, s: &str) -> String {
if let Some(t) = self.get(&s.to_string()) {
t.to_string()
} else {
s.to_string()
}
}
}
impl<T: XTr> XTr for std::sync::RwLock<T> {
fn xtr(&self, s: &str) -> String {
self.read().unwrap().xtr(s)
}
}
impl<T: XTr> XTr for std::sync::Arc<T> {
fn xtr(&self, s: &str) -> String {
(**self).xtr(s)
}
}