Skip to content

armgit / peel

Public Imported from GitHub
0

Uninstall Mac apps with every file they leave behind, and see why each belongs. Free up space, fine-tune macOS, and set up Terminal.

Info.plist's shown text reaches its catalog without a hand kept list

Țugui Dragoș87ae559e04b2
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/StringCatalogTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/StringCatalogTests.swift
index f2ff21d9..9d455f0c 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/StringCatalogTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/StringCatalogTests.swift
@@ -20,6 +20,19 @@ import Testing
#expect(checker.problems.isEmpty, "\(checker.problems.prefix(40).map(\.description).joined(separator: "\n"))")
}
+ /// Every text of Info.plist that macOS shows, its permission prompts and its copyright, is in the InfoPlist
+ /// catalog, or macOS shows it in English in every language.
+ @Test func infoPlistTextIsInItsCatalog() throws {
+ let data = try Data(contentsOf: Self.repository.appending(path: "Support/Peel-Info.plist"))
+ let plist = try #require(try PropertyListSerialization.propertyList(from: data, format: nil) as? [String: Any])
+ let shown = Set(plist.keys.filter { $0.hasSuffix("UsageDescription") || $0 == "NSHumanReadableCopyright" })
+ let checker = CatalogChecker(root: Self.repository, required: [])
+ let file = checker.load("Localization/Peel/InfoPlist.xcstrings")
+ let catalog = try #require(file?["strings"] as? [String: [String: Any]])
+ let translated = Set(catalog.filter { $0.value["shouldTranslate"] as? Bool != false }.keys)
+ #expect(shown == translated)
+ }
+
/// Items Peel puts in menus SwiftUI builds use SwiftUI's own words in each language, or the menu reads as if
/// two apps wrote it: German puts a no-break space before its ellipsis, and Traditional Chinese writes ⋯. The
/// same goes for the one name SwiftUI looks up in Peel's own strings.
diff --git a/Scripts/sync_localizations.py b/Scripts/sync_localizations.py
index 435fe68d..a67b590e 100644
--- a/Scripts/sync_localizations.py
+++ b/Scripts/sync_localizations.py
@@ -29,14 +29,6 @@ SYNCED = [
]
INFO_PLIST = PROJECT / "Support/Peel-Info.plist"
INFO_CATALOG = LOCALIZATION / "Peel/InfoPlist.xcstrings"
-# Info.plist keys whose text macOS shows, in permission prompts and in Finder's Info window.
-INFO_KEYS = [
- "NSAppDataUsageDescription",
- "NSDesktopFolderUsageDescription",
- "NSDocumentsFolderUsageDescription",
- "NSDownloadsFolderUsageDescription",
- "NSHumanReadableCopyright",
-]
NAMES = ["CFBundleDisplayName", "CFBundleName"]
CHECK = "--check" in sys.argv[1:]
FORCE = "--force" in sys.argv[1:]
@@ -98,7 +90,9 @@ def info_plist(current):
plist = plistlib.loads(INFO_PLIST.read_bytes())
strings = {}
old = keys(current)
- for key in INFO_KEYS:
+ # The keys whose text macOS shows: the permission prompts, and the copyright in Finder's Info window.
+ shown = sorted(key for key in plist if key.endswith("UsageDescription") or key == "NSHumanReadableCopyright")
+ for key in shown:
entry = dict(old.get(key, {}))
localizations = dict(entry.get("localizations", {}))
english = localizations.get("en", {}).get("stringUnit", {}).get("value")