Using heartbeat api instead
This commit is contained in:
parent
4cedb17b60
commit
d024280878
10 changed files with 319 additions and 40 deletions
13
src/i18n/translate.rs
Normal file
13
src/i18n/translate.rs
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
use crate::i18n::loader::LOCALES;
|
||||
use fluent_templates::Loader;
|
||||
use std::str::FromStr;
|
||||
use unic_langid::LanguageIdentifier;
|
||||
|
||||
fn get_sys_locale() -> LanguageIdentifier {
|
||||
let sys_lang = sys_locale::get_locale().unwrap_or_else(|| String::from("pt-BR"));
|
||||
LanguageIdentifier::from_str(&sys_lang).expect("Invalid language")
|
||||
}
|
||||
|
||||
pub fn t(key: &str) -> String {
|
||||
LOCALES.lookup(&get_sys_locale(), key)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue