import Foundation /// Every word Base shows, from `Resources/Localizable.xcstrings`. The keys /// are copy review's ids (copy-review/strings.json) and the web's approved /// copy (`ask.*`, from internal/web/templates/partials/chat.html and /// ask.js); scripts/check-strings.py holds the catalog to both. Nothing in /// the app hard-codes copy: a view shows `BaseText.text("…")`, or /// `Text(verbatim:)` for what the server or the person wrote. public enum BaseText { /// The catalog's text for `key`. public static func text(_ key: String) -> String { Bundle.module.localizedString(forKey: key, value: nil, table: nil) } /// The catalog's text for `key` with each `{name}` filled in. Copy /// review writes placeholders as `{email}`, `{team}`; the catalog keeps /// them so, and the values are never looked up themselves. public static func format(_ key: String, _ values: [String: String]) -> String { var out = text(key) for (name, value) in values { out = out.replacingOccurrences(of: "{\(name)}", with: value) } return out } /// A plural entry (copy review's "Plural in the String Catalog"): the /// catalog's forms select on `count`, written `%lld` there. public static func plural(_ key: String, _ count: Int) -> String { String.localizedStringWithFormat(text(key), count) } }