chore: use LazyLock instead of lazy_static!
This commit is contained in:
parent
a20d77fea4
commit
97027e69c3
4 changed files with 15 additions and 23 deletions
|
|
@ -1,6 +1,6 @@
|
|||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
use std::str::FromStr;
|
||||
use std::{str::FromStr, sync::LazyLock};
|
||||
|
||||
use i18n_embed::{
|
||||
fluent::{fluent_language_loader, FluentLanguageLoader},
|
||||
|
|
@ -14,20 +14,17 @@ use rust_embed::RustEmbed;
|
|||
#[folder = "i18n/"]
|
||||
struct Localizations;
|
||||
|
||||
lazy_static::lazy_static! {
|
||||
pub static ref LANGUAGE_LOADER: FluentLanguageLoader = {
|
||||
let loader: FluentLanguageLoader = fluent_language_loader!();
|
||||
pub static LANGUAGE_LOADER: LazyLock<FluentLanguageLoader> = LazyLock::new(|| {
|
||||
let loader: FluentLanguageLoader = fluent_language_loader!();
|
||||
|
||||
loader
|
||||
.load_fallback_language(&Localizations)
|
||||
.expect("Error while loading fallback language");
|
||||
loader
|
||||
.load_fallback_language(&Localizations)
|
||||
.expect("Error while loading fallback language");
|
||||
|
||||
loader
|
||||
};
|
||||
}
|
||||
loader
|
||||
});
|
||||
|
||||
lazy_static::lazy_static! {
|
||||
pub static ref LANGUAGE_SORTER: Collator = {
|
||||
pub static LANGUAGE_SORTER: LazyLock<Collator> = LazyLock::new(|| {
|
||||
let mut options = CollatorOptions::new();
|
||||
options.numeric = Some(Numeric::On);
|
||||
|
||||
|
|
@ -40,8 +37,7 @@ lazy_static::lazy_static! {
|
|||
Collator::try_new(&locale, options).ok()
|
||||
})
|
||||
.expect("Creating a collator from the system's current language, the fallback language, or American English should succeed")
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! fl {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue