mirror of
https://github.com/johrpan/musicus.git
synced 2025-10-28 12:47:25 +01:00
Use LazyLock instead of lazy_static
This commit is contained in:
parent
3904b62c2c
commit
41c2a9c1fc
3 changed files with 13 additions and 16 deletions
27
src/util.rs
27
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<String> = 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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue