import Foundation /// A backend that resolves localized strings for an explicit locale and reports the languages it serves. /// /// This is the seam that decouples ``Localize`` and ``LanguageList`` from *how* localizations are stored /// and resolved. The shipping implementation, ``StringCatalog``, reads a raw `.xcstrings` catalog so it /// behaves identically on Darwin and Linux. A future backend — for example one built on /// `String(localized:)` for a native Apple app that needs plural and device variations — can conform /// without changing any caller. /// /// Resolution never fails: an implementation returns the key itself when it has no localization for it, /// mirroring Foundation's `String(localized:)`. This is the contract both a dictionary lookup and the /// native API can honour, since the native API cannot distinguish a missing key from a translation that /// happens to equal the key. protocol CatalogResolving: Sendable { // MARK: Properties /// The source (development) language, used as the final fallback when a locale has no localization. var sourceLanguage: String { get } /// Every language the backend can resolve strings for, including the source language. var languages: Set { get } // MARK: Methods /// Resolves a catalog key in the given locale. /// - Parameters: /// - key: the catalog key to look up. /// - locale: the locale to resolve the key in. /// - Returns: the localized string, falling back to the source language, then to the key itself. func string( for key: String, in locale: Locale ) -> String }