Skip to content

Commit

Permalink
refactor: simplify localized name retrieval in macos_app_from_path
Browse files Browse the repository at this point in the history
  • Loading branch information
BennoCrafter committed Feb 12, 2025
1 parent c8f0172 commit 6458d09
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions rust/plugin_runtime/src/plugins/applications/macos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,18 +174,17 @@ pub fn macos_app_from_path(path: &Path, lang: Option<String>) -> Option<DesktopP
if !path.is_dir() {
return None;
}
let name: String;

if let Some(lang) = lang {
let info_plist_path = path.join("Contents/Resources/InfoPlist.loctable");
if info_plist_path.is_file() {
name = get_localized_name(info_plist_path.as_path(), &lang).unwrap_or(get_bundle_name(path));
} else {
name = get_bundle_name(path);
}
} else {
name = get_bundle_name(path);
}

let name = lang.
and_then(|l| {
let info_plist_path = path.join("Contents/Resources/InfoPlist.loctable");
if info_plist_path.is_file() {
get_localized_name(info_plist_path.as_path(), &l)
} else {
None
}
})
.unwrap_or(get_bundle_name(path));

let icon = get_application_icon(&path)
.inspect_err(|err| tracing::error!("error while reading application icon for {:?}: {:?}", path, err))
Expand Down

0 comments on commit 6458d09

Please sign in to comment.