Skip to content

Commit

Permalink
fix: pick default language from available languages
Browse files Browse the repository at this point in the history
  • Loading branch information
Kneemund committed Nov 2, 2024
1 parent 77677f1 commit 4bdbc34
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions crates/rnote-engine/src/engine/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ use std::fmt::Debug;
use std::path::PathBuf;
use std::sync::Arc;
use std::time::Instant;
use tracing::error;
use tracing::{debug, error};

pub struct Spellchecker {
broker: enchant::Broker,
Expand All @@ -44,9 +44,22 @@ pub struct Spellchecker {

impl Spellchecker {
pub fn default_language() -> Option<String> {
glib::language_names()
.get(0)
.map(|language| language.to_string())
let available_languages = Self::available_languages();

for system_language in glib::language_names() {
for available_language in &available_languages {
if system_language.contains(available_language) {
debug!(
"found default spellcheck language: {:?}",
available_language
);

return Some(available_language.to_string());
}
}
}

None
}

pub fn available_languages() -> Vec<String> {
Expand Down

0 comments on commit 4bdbc34

Please sign in to comment.