🔥 Use L10n component for translating texts
This commit is contained in:
parent
c9f71685b4
commit
3c5da6936e
2 changed files with 1 additions and 22 deletions
|
|
@ -161,24 +161,3 @@ macro_rules! static_locales {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#[macro_export]
|
|
||||||
macro_rules! t {
|
|
||||||
( $langid:expr, $locales:expr, $key:expr ) => {
|
|
||||||
$locales.lookup($langid, $key).unwrap_or($key.to_string())
|
|
||||||
};
|
|
||||||
( $langid:expr, $locales:expr, $key:expr, $args:expr ) => {
|
|
||||||
$locales
|
|
||||||
.lookup_with_args(
|
|
||||||
$langid,
|
|
||||||
$key,
|
|
||||||
&$args
|
|
||||||
.iter()
|
|
||||||
.fold(std::collections::HashMap::new(), |mut a, (k, v)| {
|
|
||||||
a.insert(k.to_string(), v.to_owned().into());
|
|
||||||
a
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
.unwrap_or($key.to_string())
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ pub use crate::{kv, new_handle};
|
||||||
// crate::config
|
// crate::config
|
||||||
pub use crate::default_settings;
|
pub use crate::default_settings;
|
||||||
// crate::locale
|
// crate::locale
|
||||||
pub use crate::{static_locales, t};
|
pub use crate::static_locales;
|
||||||
// crate::service
|
// crate::service
|
||||||
pub use crate::{static_files, static_files_service};
|
pub use crate::{static_files, static_files_service};
|
||||||
// crate::core::action
|
// crate::core::action
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue