Uninstall Mac apps with every file they leave behind, and see why each belongs. Free up space, fine-tune macOS, and set up Terminal.
Swift cache-cleanercleanerclideveloper-toolsdisk-cleanupdisk-spaceduplicate-finderhomebrewliquid-glassmac-cleanermacosmacos-appmacos-golden-gatemacos-tahoemacos-tweaksswiftswiftuiterminal-themesuninstalluninstaller
Word what Remove Peel leaves behind in the reader's language
Țugui Dragoș16e66ce0d32b
diff --git a/Peel/Model/SelfUninstall.swift b/Peel/Model/SelfUninstall.swiftindex 5cb1c56d..c8da05b2 100644--- a/Peel/Model/SelfUninstall.swift+++ b/Peel/Model/SelfUninstall.swift@@ -12,6 +12,9 @@ final class SelfUninstall {/// What stayed after the app itself moved to the Trash: files, and a login item. Peel is running from the Trash by/// then, so the alert that lists them has a single button, which quits.private(set) var leftBehind: String?+ /// Where Peel's words are read once it is in the Trash: the folder of the language it was using, there, since the+ /// main bundle still names the place Peel left. Nil reads them from the main bundle.+ private(set) var words: Bundle?static var removeCommand: String {"sudo rm -f /usr/local/bin/peel"@@ -87,6 +90,7 @@ final class SelfUninstall {// Unregistering a login item that was never registered fails too, so what counts is whether it is still there.try? await SMAppService.mainApp.unregister()let opensAtLogin = [.enabled, .requiresApproval].contains(SMAppService.mainApp.status)+ let language = Bundle.main.preferredLocalizations.firstlet result = await SelfRemoval.move(urls,@@ -103,14 +107,17 @@ final class SelfUninstall {return}SelfRemoval.endExtensions(runningFrom: moved.trashedURL)+ words = language.flatMap {+ Bundle(url: moved.trashedURL.appending(path: "Contents/Resources/\($0).lproj", directoryHint: .isDirectory))+ }_ = await DockTiles().takeOut([bundleURL], remembering: false)var stayed = result.failures + links.failuresif case .stayed(let failure) = ledger {stayed.append(failure)}- var lines = stayed.map { "\($0.url.abbreviatedPath)\n\($0.reason.explanation)" }+ var lines = stayed.map { "\($0.url.abbreviatedPath)\n\($0.reason.explanation(in: words))" }if opensAtLogin {- lines.append(String(localized: "Peel is still set to open at login: remove it in System Settings > General > Login Items & Extensions."))+ lines.append(String(localized: "Peel is still set to open at login: remove it in System Settings > General > Login Items & Extensions.", bundle: words))}guard lines.isEmpty else {leftBehind = lines.joined(separator: "\n\n")diff --git a/Peel/Views/FixedSentenceText.swift b/Peel/Views/FixedSentenceText.swiftindex aecc7ac3..bde9b829 100644--- a/Peel/Views/FixedSentenceText.swift+++ b/Peel/Views/FixedSentenceText.swift@@ -40,8 +40,16 @@ extension FixedSentence {}/// What PeelCore or the helper sent, in the reader's language when it is one of these, as it came otherwise.- static func translated(_ message: String) -> String {- FixedSentence(message).map { String(localized: $0.words) } ?? message+ static func translated(_ message: String, in bundle: Bundle? = nil) -> String {+ FixedSentence(message).map { $0.words.resolved(in: bundle) } ?? message+ }+}++extension LocalizedStringResource {+ /// The words as Foundation resolves them, or from `bundle` by their key: only for a sentence with no arguments.+ func resolved(in bundle: Bundle?) -> String {+ guard let bundle else { return String(localized: self) }+ return String(localized: String.LocalizationValue(key), table: table, bundle: bundle, locale: locale)}}diff --git a/Peel/Views/Presentation.swift b/Peel/Views/Presentation.swiftindex 82f61be3..4e7e860c 100644--- a/Peel/Views/Presentation.swift+++ b/Peel/Views/Presentation.swift@@ -161,30 +161,35 @@ extension GuardRefusal {extension TrashFailure.Reason {/// What went wrong with one item of a removal, in words for the user who asked to move it.var explanation: String {+ explanation(in: nil)+ }++ /// The explanation read from `bundle`, or from the main bundle when it is nil.+ func explanation(in bundle: Bundle?) -> String {switch self {- case .guarded(let refusal?): String(localized: refusal.explanation)- case .guarded(nil): String(localized: "Peel won’t move this: it is protected, or your exclusions in Settings keep it where it is.")- case .changedSinceScan: String(localized: "It changed after Peel looked at it. Scan again to review it.")- case .claimedSinceScan: String(localized: "Peel couldn’t confirm it is still nobody’s: an installed app may claim it now. Scan again to review it.")- case .lastCopy: String(localized: "The copy Peel was keeping has changed or moved since the scan, so this one may be the last.")- case .notPermitted: String(localized: "macOS didn’t allow it.")- case .locked: String(localized: "It is locked. In Finder, choose File > Get Info and deselect Locked, then try again.")- case .needsHelper: String(localized: "It needs administrator access, which Peel’s helper provides.")- case .movedWithoutATrace: String(localized: "It is in the Trash, but macOS didn’t say where, so it can only be put back from Finder.")- case .somethingElseMoved(let name): String(localized: "Something else was at that path by the time it moved. It is in the Trash as \(name), and Finder can put it back.")- case .historyUnreadable: String(localized: "Peel couldn’t read History, and it moves nothing it can’t put back.")+ case .guarded(let refusal?): refusal.explanation.resolved(in: bundle)+ case .guarded(nil): String(localized: "Peel won’t move this: it is protected, or your exclusions in Settings keep it where it is.", bundle: bundle)+ case .changedSinceScan: String(localized: "It changed after Peel looked at it. Scan again to review it.", bundle: bundle)+ case .claimedSinceScan: String(localized: "Peel couldn’t confirm it is still nobody’s: an installed app may claim it now. Scan again to review it.", bundle: bundle)+ case .lastCopy: String(localized: "The copy Peel was keeping has changed or moved since the scan, so this one may be the last.", bundle: bundle)+ case .notPermitted: String(localized: "macOS didn’t allow it.", bundle: bundle)+ case .locked: String(localized: "It is locked. In Finder, choose File > Get Info and deselect Locked, then try again.", bundle: bundle)+ case .needsHelper: String(localized: "It needs administrator access, which Peel’s helper provides.", bundle: bundle)+ case .movedWithoutATrace: String(localized: "It is in the Trash, but macOS didn’t say where, so it can only be put back from Finder.", bundle: bundle)+ case .somethingElseMoved(let name): String(localized: "Something else was at that path by the time it moved. It is in the Trash as \(name), and Finder can put it back.", bundle: bundle)+ case .historyUnreadable: String(localized: "Peel couldn’t read History, and it moves nothing it can’t put back.", bundle: bundle)case .heldOpen(let processes) where processes.count > 1:- String(localized: "It is in use by \(processes.formatted(.list(type: .and))). Quit \(processes.formatted(.list(type: .and))), or stop them in Background Items if they have no window, then try again.")+ String(localized: "It is in use by \(processes.formatted(.list(type: .and))). Quit \(processes.formatted(.list(type: .and))), or stop them in Background Items if they have no window, then try again.", bundle: bundle)case .heldOpen(let processes):- String(localized: "It is in use by \(processes.formatted(.list(type: .and))). Quit \(processes.formatted(.list(type: .and))), or stop it in Background Items if it has no window, then try again.")- case .peelRunsFromIt: String(localized: "Peel itself runs from here, and only Remove Peel, in Settings > General, removes Peel.")+ String(localized: "It is in use by \(processes.formatted(.list(type: .and))). Quit \(processes.formatted(.list(type: .and))), or stop it in Background Items if it has no window, then try again.", bundle: bundle)+ case .peelRunsFromIt: String(localized: "Peel itself runs from here, and only Remove Peel, in Settings > General, removes Peel.", bundle: bundle)case .heldByAnotherAccount(let processes) where processes.count > 1:- String(localized: "It is in use by \(processes.formatted(.list(type: .and))), which run as another account or as the system, so neither you nor Peel can quit them. Stop them in Background Items, or with the app’s own uninstaller, then try again.")+ String(localized: "It is in use by \(processes.formatted(.list(type: .and))), which run as another account or as the system, so neither you nor Peel can quit them. Stop them in Background Items, or with the app’s own uninstaller, then try again.", bundle: bundle)case .heldByAnotherAccount(let processes):- String(localized: "It is in use by \(processes.formatted(.list(type: .and))), which runs as another account or as the system, so neither you nor Peel can quit it. Stop it in Background Items, or with the app’s own uninstaller, then try again.")+ String(localized: "It is in use by \(processes.formatted(.list(type: .and))), which runs as another account or as the system, so neither you nor Peel can quit it. Stop it in Background Items, or with the app’s own uninstaller, then try again.", bundle: bundle)case .inUseByMacOS(let processes):- String(localized: "macOS is using it right now, through \(processes.formatted(.list(type: .and))), so it stays where it is.")- case .failed(let message): FixedSentence.translated(message)+ String(localized: "macOS is using it right now, through \(processes.formatted(.list(type: .and))), so it stays where it is.", bundle: bundle)+ case .failed(let message): FixedSentence.translated(message, in: bundle)}}}diff --git a/Peel/Views/Settings/SettingsView.swift b/Peel/Views/Settings/SettingsView.swiftindex cf8b2e3e..3e4bc012 100644--- a/Peel/Views/Settings/SettingsView.swift+++ b/Peel/Views/Settings/SettingsView.swift@@ -482,8 +482,11 @@ private struct GeneralSettingsView: View {} message: {Text(verbatim: selfUninstall.failure ?? "")}- .alert("Peel is in the Trash, but a few things stayed behind.", isPresented: .constant(selfUninstall.leftBehind != nil)) {- Button("Quit Peel") { selfUninstall.quit() }+ .alert(+ Text("Peel is in the Trash, but a few things stayed behind.", bundle: selfUninstall.words),+ isPresented: .constant(selfUninstall.leftBehind != nil)+ ) {+ Button { selfUninstall.quit() } label: { Text("Quit Peel", bundle: selfUninstall.words) }} message: {Text(verbatim: selfUninstall.leftBehind ?? "")}