diff --git a/Cargo.lock b/Cargo.lock index b78e6d8..2c4e493 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1880,7 +1880,6 @@ dependencies = [ "glib", "gstreamer-play", "gtk4", - "lazy_static", "libadwaita", "log", "mpris-server", diff --git a/Cargo.toml b/Cargo.toml index 4f0b267..ac6b612 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,6 @@ gettext-rs = { version = "0.7", features = ["gettext-system"] } glib = { version = "0.20", features = ["v2_84"] } gstreamer-play = "0.23" gtk = { package = "gtk4", version = "0.9", features = ["v4_18", "blueprint"] } -lazy_static = "1" log = "0.4" mpris-server = "0.8" once_cell = "1" diff --git a/src/util.rs b/src/util.rs index 6358704..ecf9f07 100644 --- a/src/util.rs +++ b/src/util.rs @@ -2,27 +2,26 @@ pub mod activatable_row; pub mod drag_widget; pub mod error_dialog; +use std::sync::LazyLock; + use gettextrs::gettext; use gtk::glib::{self, clone}; -use lazy_static::lazy_static; use error_dialog::ErrorDialog; -lazy_static! { - /// The user's language code. - pub static ref LANG: String = { - let lang = match glib::language_names().first() { - Some(language_name) => match language_name.split('_').next() { - Some(lang) => lang.to_string(), - None => "generic".to_string(), - }, +/// The user's language code. +pub static LANG: LazyLock = LazyLock::new(|| { + let lang = match glib::language_names().first() { + Some(language_name) => match language_name.split('_').next() { + Some(lang) => lang.to_string(), None => "generic".to_string(), - }; - - log::info!("Intialized user language to '{lang}'."); - lang + }, + None => "generic".to_string(), }; -} + + log::info!("Intialized user language to '{lang}'."); + lang +}); /// Create and show an error toast. This will also log the error to the console. pub fn error_toast(msgid: &str, err: anyhow::Error, toast_overlay: &adw::ToastOverlay) {