// The sentences the app shares, and the one function they go through. // // The phone's 3,101 Lingui entries retire with the runtime that minted them // (design P20): the hashed keys are Lingui's own generated ids, meaningless // outside it, and the three ~1.5 %-translated locales go with them. What // replaces them is a Swift string catalogue holding the same sentences, keyed // by the English text itself — so a key that is never translated still renders // correctly, which is the English-only policy stated as a mechanism rather than // as a promise ([english-only-no-translations]). // // **COPY LIVES AT THE CALL SITE, as a literal, since I4** — `Text("Done")`, // `ScreenBar(title: "Todos")`, `toasts.show("Archived")`. A sentence is now // read where it is drawn, and the ~2,700 members that used to stand between the // two are gone. A member survives HERE on one test: the same sentence is said // in three or more places, and a sentence said in several places needs ONE // spelling — change it once and every screen saying it changes with it. Two // call sites is a coincidence; three is a fact about the app. // `Strings+Boot.swift` and `Strings+Legal.swift` keep their whole tables // whatever the count, because tests pin those sentences word for word and the // table is where the test reads them. // // Nothing went unguarded in that move. `LanguageSweepTests` reads every source // under `Sources/`, so a literal written inside a view body is swept for the // retired terms and for a boundary method name exactly as a member here was. // // **THE CATALOGUE IS A PARTIAL RECORD, ON PURPOSE, and this is where that is // stated** (the 4e review, S45: one lane catalogued its ~214 sentences and the // next did not catalogue its ~613, a day apart, with nothing saying which was // right). Both render correctly, because `local` passes NO `defaultValue:` — // the key IS the English, so an uncatalogued sentence is its own value. What // the catalogue adds is a place a translator would work and a count a tool can // read, and under [english-only-no-translations] neither is load-bearing today. // Since I4 it holds only what still goes through `local`, which is the tables // and nothing else: `scripts/ios-strings-catalogue.mjs` derives its keys from // the `local("…")` calls, `--write` adds the ones missing, and `--stale` // reports — with `--write`, deletes — the entries no table says any more. So // the rule is: the SOURCE is the one place English lives, the catalogue is a // convenience that may lag it, and the day a second language is real it stops // being optional and that is a lane of its own. import CottonKit import Foundation public enum CottonStrings { /// The catalogue's sentence, said in this app's name (`FlavourManifest.said`). static func local(_ value: String.LocalizationValue) -> String { ShellLines.said(catalogued(value), as: ShellLines.speaker) } private static func catalogued(_ value: String.LocalizationValue) -> String { #if canImport(UIKit) String(localized: value, bundle: .module) #else // THE MAC READS THE KEY. English is the only language and the key IS // the sentence, so what the catalogue would answer is what this // answers. It could not read the catalogue anyway: `swift build` // ships `Localizable.xcstrings` uncompiled, and `Bundle.module` on an // installed copy is a `fatalError` (the accessor looks beside the // executable and in the build directory; a packaged app has neither). // `ResourceBundleGuardTests` holds that nothing the Mac compiles // reaches `.module` outside a UIKit-only region. String(localized: value) #endif } // ── Dates and lateness ──────────────────────────────────────────────── public static var justNow: String { ShellLines.line("words", "just_now") } /// A stated hour that has passed today: the count of days would be a lie. public static var lateBare: String { ShellLines.line("words", "late_bare") } public static func daysLate(_ n: Int) -> String { ShellLines.line("words", n == 1 ? "days_late.one" : "days_late.many", ["n": "\(n)"]) } // ── Summaries ───────────────────────────────────────────────────────── public static var you: String { ShellLines.line("words", "you") } public static var tryAgain: String { ShellLines.line("words", "try_again") } /// One call site, kept here because `LanguageSweepTests` pins the sentence /// as a catalogue key and a key needs a `local()` producer. public static var sentToASession: String { ShellLines.line("words", "sent_to_asession") } // ── Chrome ──────────────────────────────────────────────────────────── public static var back: String { ShellLines.line("words", "back") } /// A record's X: it closes the record, one level (fan3 part 10). public static var close: String { ShellLines.line("words", "close") } public static var search: String { ShellLines.line("words", "search") } public static var cancel: String { ShellLines.line("words", "cancel") } public static var undo: String { ShellLines.line("words", "undo") } /// Where a record goes when it leaves a list — a bar's title, a menu's /// verb, a receipt. Said across six lanes (mail, chats, notes, people, /// places and the Work screens), which is why it is one member and not six. public static var archived: String { ShellLines.line("words", "archived") } // ── The tools' own names ────────────────────────────────────────────── // // A tool's proper noun is said by Home's tools directory AND by the tool's // own bar, so it is one word here rather than one per lane. The SLUG is // never this — `accounts` stays a route segment and a cache key. public static var projects: String { ShellLines.line("words", "projects") } public static var money: String { ShellLines.line("words", "money") } }