mirror of
https://github.com/johrpan/musicus.git
synced 2025-10-27 04:07:25 +01:00
Get user language from GLib
This commit is contained in:
parent
220821a0e0
commit
3c8f5b8c31
5 changed files with 24 additions and 4 deletions
18
src/util.rs
Normal file
18
src/util.rs
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
use gtk::glib;
|
||||
use lazy_static::lazy_static;
|
||||
|
||||
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(),
|
||||
},
|
||||
None => "generic".to_string(),
|
||||
};
|
||||
|
||||
log::info!("Intialized user language to '{lang}'.");
|
||||
lang
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue