Skip to content

Commit

Permalink
Merge pull request #283 from cortex/correct-translation-file-location
Browse files Browse the repository at this point in the history
Correct translation file location
  • Loading branch information
alexanderkjall authored Feb 11, 2023
2 parents f4534ab + f31a2bb commit 40ed8c3
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion cursive/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1073,7 +1073,7 @@ fn do_delete_last_word(ui: &mut Cursive, store: PasswordStoreType) {
fn get_translation_catalog() -> gettext::Catalog {
let locale = locale_config::Locale::current();

let mut translation_locations = vec!["/usr/share/ripasso"];
let mut translation_locations = vec![];
if let Some(path) = option_env!("TRANSLATION_INPUT_PATH") {
translation_locations.insert(0, path);
}
Expand All @@ -1097,6 +1097,22 @@ fn get_translation_catalog() -> gettext::Catalog {
}
}

for preferred in locale.tags_for("messages") {
let langid_res: std::result::Result<LanguageIdentifier, _> = format!("{preferred}").parse();

if let Ok(langid) = langid_res {
let file = std::fs::File::open(format!(
"/usr/share/locale/{}/LC_MESSAGES/ripasso-cursive.mo",
langid.language
));
if let Ok(file) = file {
if let Ok(catalog) = gettext::Catalog::parse(file) {
return catalog;
}
}
}
}

gettext::Catalog::empty()
}

Expand Down

0 comments on commit 40ed8c3

Please sign in to comment.