mirror of
https://github.com/an-anime-team/an-anime-game-launcher.git
synced 2025-02-16 15:22:01 +03:00
feat(core): slightly optimized tr!
macro
This commit is contained in:
parent
7492aad669
commit
06db94de58
1 changed files with 6 additions and 7 deletions
13
src/i18n.rs
13
src/i18n.rs
|
@ -109,15 +109,14 @@ macro_rules! tr {
|
|||
use fluent_templates::Loader;
|
||||
use fluent_templates::fluent_bundle::FluentValue;
|
||||
|
||||
let mut args = std::collections::HashMap::new();
|
||||
|
||||
for (key, value) in $args {
|
||||
args.insert(key, FluentValue::from(value));
|
||||
}
|
||||
|
||||
#[allow(unused_unsafe)]
|
||||
$crate::i18n::LOCALES
|
||||
.lookup_with_args(unsafe { &$crate::i18n::LANG }, $id, &args)
|
||||
.lookup_with_args(
|
||||
unsafe { &$crate::i18n::LANG },
|
||||
$id,
|
||||
&std::collections::HashMap::from_iter($args.into_iter()
|
||||
.map(|(key, value)| (key, FluentValue::from(value))))
|
||||
)
|
||||
.expect(&format!("Failed to find a message with given id: {}", stringify!($id)))
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue