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.

Credit blueprint in a Debug build's About

Țugui Dragoș9d65e45ca4a2
diff --git a/AGENTS.md b/AGENTS.md
index 4962f2c4..d62eb756 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -423,12 +423,14 @@ Peel runs on macOS 26 and later, and the two versions are treated differently in
Romanian, German, French, Spanish, Portuguese (Brazilian), Italian, Japanese, Simplified and Traditional
Chinese, Dutch, Korean, Russian, Polish, Turkish, Swedish, Czech, and Ukrainian.
- Write new or changed interface text in English, then run `python3 Scripts/sync_localizations.py` after a Debug
- build so the catalogs list it. In the Localizable and AppShortcuts catalogs the English is the key, so new text has
+ build so the catalogs list it. In every catalog but InfoPlist the English is the key, so new text has
no translations, and changed text is new text: the sync keeps the entry of the text it replaced, marked stale with
its translations. `StringCatalogTests` fails for both until all 17 are written for the new text and the stale entry
is gone, which happens before the change is merged. Text an Info.plist shows (a permission prompt, the copyright)
keeps its key, and its translations are marked for review until they are written again.
- Text a person reads goes through the catalogs: `Text(verbatim:)` is only for what is not words, or for a name.
+ Text that only a Debug build shows (inside `#if DEBUG`) takes the `DebugBuild` table (`tableName: "DebugBuild"`),
+ whose catalog the Release configuration leaves out (`EXCLUDED_SOURCE_FILE_NAMES`), so a release carries none of it.
- A translation uses the words macOS itself uses in that language for every place, menu, and command, and writes the
marks macOS writes there: Dutch keeps the straight apostrophe, German puts a no-break space before an ellipsis,
French one before ? : ! and ; and inside « », App Store keeps one in the languages whose macOS writes it so, and
diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md
index 5029264b..35ce411b 100644
--- a/ARCHITECTURE.md
+++ b/ARCHITECTURE.md
@@ -284,7 +284,8 @@ macOS asks the user to approve it once. It talks to the app over XPC.
- **Languages.** Every string a person reads is in the string catalogs in `Localization/`, translated into 17
languages. The key is the English, so changing a sentence means translating it again; the tests fail until
every language has it. PeelCore never translates: it returns plain English, and the app turns known
- sentences into the reader's language (`FixedSentence`).
+ sentences into the reader's language (`FixedSentence`). What only a Debug build shows is in
+ `DebugBuild.xcstrings`, which the Release configuration leaves out.
- **Tweaks.** The Tweaks page changes 40 settings of macOS and of its apps, each one preference key of one domain
(`TweakCatalog`), through CFPreferences and never by editing a file: cfprefsd keeps its own copy of a domain and
writes it back over a file changed behind it (`TweakStore`). It writes the layer System Settings writes, the
diff --git a/Localization/Peel/DebugBuild.xcstrings b/Localization/Peel/DebugBuild.xcstrings
new file mode 100644
index 00000000..4ede3df1
--- /dev/null
+++ b/Localization/Peel/DebugBuild.xcstrings
@@ -0,0 +1,113 @@
+{
+ "sourceLanguage" : "en",
+ "strings" : {
+ "The DEV icon is made with [blueprint](https://github.com/MustafaNatur/blueprint)" : {
+ "comment" : "Only in a Debug build of Peel, whose icon wears a DEV badge and is drawn by blueprint, an open source tool. Keep the link as it is.",
+ "localizations" : {
+ "cs" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Ikona DEV je vytvořena nástrojem [blueprint](https://github.com/MustafaNatur/blueprint)"
+ }
+ },
+ "de" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Das DEV-Symbol wurde mit [blueprint](https://github.com/MustafaNatur/blueprint) erstellt"
+ }
+ },
+ "es" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "El icono DEV está hecho con [blueprint](https://github.com/MustafaNatur/blueprint)"
+ }
+ },
+ "fr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "L’icône DEV est créée avec [blueprint](https://github.com/MustafaNatur/blueprint)"
+ }
+ },
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "L’icona DEV è creata con [blueprint](https://github.com/MustafaNatur/blueprint)"
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "DEVアイコンは[blueprint](https://github.com/MustafaNatur/blueprint)で作成しています"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "DEV 아이콘은 [blueprint](https://github.com/MustafaNatur/blueprint)를 사용하여 만들었습니다"
+ }
+ },
+ "nl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Het DEV-symbool is gemaakt met [blueprint](https://github.com/MustafaNatur/blueprint)"
+ }
+ },
+ "pl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Ikonę DEV utworzono za pomocą [blueprint](https://github.com/MustafaNatur/blueprint)"
+ }
+ },
+ "pt" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "O ícone DEV é feito com o [blueprint](https://github.com/MustafaNatur/blueprint)"
+ }
+ },
+ "ro" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Pictograma DEV este făcută cu [blueprint](https://github.com/MustafaNatur/blueprint)"
+ }
+ },
+ "ru" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Значок DEV создан с помощью [blueprint](https://github.com/MustafaNatur/blueprint)"
+ }
+ },
+ "sv" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "DEV-symbolen är skapad med [blueprint](https://github.com/MustafaNatur/blueprint)"
+ }
+ },
+ "tr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "DEV simgesi [blueprint](https://github.com/MustafaNatur/blueprint) ile oluşturulmuştur"
+ }
+ },
+ "uk" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Іконку DEV створено за допомогою [blueprint](https://github.com/MustafaNatur/blueprint)"
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "DEV图标使用[blueprint](https://github.com/MustafaNatur/blueprint)制作"
+ }
+ },
+ "zh-Hant" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "DEV圖像使用[blueprint](https://github.com/MustafaNatur/blueprint)製作"
+ }
+ }
+ }
+ }
+ },
+ "version" : "1.0"
+}
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/DebugBuildTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/DebugBuildTests.swift
index 2b04ea86..21023269 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/DebugBuildTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/DebugBuildTests.swift
@@ -37,4 +37,12 @@ struct DebugBuildTests {
#expect(blueprint.map(\.name) == ["Badge"] + original.map(\.name) + ["Blueprint Paper"])
#expect(Array(blueprint.dropFirst().prefix(original.count)).map(\.layers) == original.map(\.layers))
}
+
+ @Test func aReleaseLeavesOutTheStringsOnlyADebugBuildShows() {
+ let leavingThemOut = configurations.filter {
+ $0.settings.contains("EXCLUDED_SOURCE_FILE_NAMES = DebugBuild.xcstrings;")
+ }
+ #expect(leavingThemOut.map(\.name) == ["Release"])
+ #expect(leavingThemOut.allSatisfy { $0.settings.contains("INFOPLIST_FILE = \"Support/Peel-Info.plist\";") })
+ }
}
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/StringCatalogTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/StringCatalogTests.swift
index 5dfefe70..5ef79efd 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/StringCatalogTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/StringCatalogTests.swift
@@ -12,6 +12,7 @@ import Testing
Catalog(path: "Localization/Peel/InfoPlist.xcstrings", table: .infoPlist),
Catalog(path: "Localization/PeelFinder/InfoPlist.xcstrings", table: .infoPlist),
Catalog(path: "Localization/Peel/AppShortcuts.xcstrings", table: .appShortcuts),
+ Catalog(path: "Localization/Peel/DebugBuild.xcstrings", table: .localizable),
]
@Test(arguments: catalogs) func everyDeclaredLanguageIsCompleteAndSound(catalog: Catalog) throws {
@@ -155,6 +156,37 @@ import Testing
#expect(problems.isEmpty, "\(problems.joined(separator: "\n"))")
}
+ @Test func everyAboutCreditFitsOnOneLine() throws {
+ let localizable = try Self.localizable()
+ let debugBuild = try Self.strings(in: "Localization/Peel/DebugBuild.xcstrings")
+ let credits = [
+ (localizable, "The peel command uses [swift-argument-parser](peel-license:swift-argument-parser-LICENSE)"),
+ (localizable, "The face’s motion is adapted from [blobatar](peel-license:blobatar-LICENSE)"),
+ (debugBuild, "The DEV icon is made with [blueprint](https://github.com/MustafaNatur/blueprint)"),
+ (localizable, "Peel updates itself with [Sparkle](peel-license:Sparkle-LICENSE)"),
+ ]
+ let aboutWidth: CGFloat = 380
+ let padding: CGFloat = 32
+ let callout = NSFont.preferredFont(forTextStyle: .callout)
+ var problems: [String] = []
+ for language in try ["en"] + Self.declaredLanguages() {
+ let font = Self.font(callout, in: language)
+ for (catalog, key) in credits {
+ guard catalog[key] != nil else {
+ problems.append("\(key.debugDescription) is not in the catalog")
+ continue
+ }
+ let text = (Self.value(of: key, in: language, catalog) ?? key)
+ .replacing(/\[([^\]]+)\]\([^)]+\)/) { String($0.output.1) }
+ let width = (text as NSString).size(withAttributes: [.font: font]).width
+ if width > aboutWidth - 2 * padding {
+ problems.append("\(language): \(text.debugDescription) is \(Int(width.rounded(.up))) points, and About has \(Int(aboutWidth - 2 * padding))")
+ }
+ }
+ }
+ #expect(problems.isEmpty, "\(problems.joined(separator: "\n"))")
+ }
+
static let sidebarNames = [
"Home", "Tweaks", "Terminal", "History", "Settings", "Applications", "Orphaned Files", "Intel Software",
"Package Receipts", "Space", "Developer", "Build Artifacts", "Installers and Backups", "Duplicates",
@@ -165,8 +197,12 @@ import Testing
static let sidebarSymbol: CGFloat = 26
static func localizable() throws -> [String: [String: Any]] {
+ try strings(in: "Localization/Peel/Localizable.xcstrings")
+ }
+
+ static func strings(in path: String) throws -> [String: [String: Any]] {
let checker = CatalogChecker(root: repository, required: [])
- return try #require(checker.load("Localization/Peel/Localizable.xcstrings")?["strings"] as? [String: [String: Any]])
+ return try #require(checker.load(path)?["strings"] as? [String: [String: Any]])
}
static func value(of key: String, in language: String, _ catalog: [String: [String: Any]]) -> String? {
diff --git a/Peel.xcodeproj/project.pbxproj b/Peel.xcodeproj/project.pbxproj
index 61197ebb..15210ebe 100644
--- a/Peel.xcodeproj/project.pbxproj
+++ b/Peel.xcodeproj/project.pbxproj
@@ -974,6 +974,7 @@
ENABLE_APP_SANDBOX = NO;
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_PREVIEWS = YES;
+ EXCLUDED_SOURCE_FILE_NAMES = DebugBuild.xcstrings;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/build/SparkleBuild/Build/Products/Release",
diff --git a/Peel/Views/AboutView.swift b/Peel/Views/AboutView.swift
index c6e4d37d..d929d61a 100644
--- a/Peel/Views/AboutView.swift
+++ b/Peel/Views/AboutView.swift
@@ -90,6 +90,13 @@ struct AboutContent: View {
"The face’s motion is adapted from [blobatar](peel-license:blobatar-LICENSE)",
comment: "The face is Peel’s logo with eyes, at the head of the sidebar. Keep the link as it is."
)
+ #if DEBUG
+ Text(
+ "The DEV icon is made with [blueprint](https://github.com/MustafaNatur/blueprint)",
+ tableName: "DebugBuild",
+ comment: "Only in a Debug build of Peel, whose icon wears a DEV badge and is drawn by blueprint, an open source tool. Keep the link as it is."
+ )
+ #endif
Text(
"Peel updates itself with [Sparkle](peel-license:Sparkle-LICENSE)",
comment: "Sparkle is the open source framework that installs Peel’s updates. Keep the link as it is."
diff --git a/Scripts/sync_localizations.py b/Scripts/sync_localizations.py
index 31355558..553c2068 100644
--- a/Scripts/sync_localizations.py
+++ b/Scripts/sync_localizations.py
@@ -4,14 +4,15 @@ Run after building the Debug configuration into `build/DerivedData`:
python3 Scripts/sync_localizations.py writes the catalogs
python3 Scripts/sync_localizations.py --check writes nothing, says what would change, exits 1 if anything would
-There are five catalogs in `Localization/`: Localizable and InfoPlist for the app and for the Finder extension,
-and AppShortcuts (the phrases Siri and Spotlight match). InfoPlist holds the text macOS shows from an Info.plist,
-such as the app's permission prompts and the copyright in Finder's Info window. Apple's `xcstringstool sync`
-updates Localizable and AppShortcuts from the build's `.stringsdata` files. It adds new strings. A string that is
-not in the build output is removed when it has no translations, and otherwise marked stale with its translations
-kept. The tool picks the strings table by the catalog's file name, so each catalog is synced on a copy with the
-same name. InfoPlist has no `.stringsdata`: its English is read from the target's Info.plist in `Support/`, and the
-bundle's name is marked as never translated.
+There are six catalogs in `Localization/`: Localizable and InfoPlist for the app and for the Finder extension,
+AppShortcuts (the phrases Siri and Spotlight match), and DebugBuild, the app's strings that only a Debug build shows,
+which the Release configuration leaves out. InfoPlist holds the text macOS shows from an Info.plist, such as the app's
+permission prompts and the copyright in Finder's Info window. Apple's `xcstringstool sync` updates Localizable,
+AppShortcuts, and DebugBuild from the build's `.stringsdata` files. It adds new strings. A string that is not in the
+build output is removed when it has no translations, and otherwise marked stale with its translations kept. The tool
+picks the strings table by the catalog's file name, so each catalog is synced on a copy with the same name. InfoPlist
+has no `.stringsdata`: its English is read from the target's Info.plist in `Support/`, and the bundle's name is marked
+as never translated.
The script stops instead of guessing. It exits when there is no build output, because a sync against nothing would
treat every string as gone, and when the build is older than the code, because a sync against it would miss what
@@ -28,6 +29,7 @@ LOCALIZATION = PROJECT / "Localization"
SYNCED = [
("Peel", LOCALIZATION / "Peel/Localizable.xcstrings"),
("Peel", LOCALIZATION / "Peel/AppShortcuts.xcstrings"),
+ ("Peel", LOCALIZATION / "Peel/DebugBuild.xcstrings"),
("PeelFinder", LOCALIZATION / "PeelFinder/Localizable.xcstrings"),
]
INFO = [