import Foundation /// A BCP-47 code paired with the exact English model-card name used in the prompt. /// /// `modelName` is never localised: it is inserted into the prompt byte for byte /// (`docs/LANGUAGES.md` §4). Use `localizedDisplayName` for UI labels. public struct ModelLanguage: Sendable, Hashable, Codable, Identifiable { /// The canonical BCP-47 code, e.g. `de`, `zh-Hant` or `kk-Cyrl`. public let code: String /// The exact model-card name, e.g. `German` or `Traditional Chinese`. public let modelName: String /// The English display name, used as a fallback when `Locale` has no localised name. public let displayName: String /// True for right-to-left scripts. public let isRTL: Bool /// True for scripts that use the smaller chunk limit. public let usesDenseScript: Bool /// `Identifiable` conformance for UI lists. public var id: String { code } /// The display name in the current UI locale, never used in a prompt. When the locale only /// has a generic name (for example “Chinese”), the catalogue's more specific name wins. public var localizedDisplayName: String { let localized = Locale.current.localizedString(forLanguageCode: code) if let localized, localized.caseInsensitiveCompare(modelName) != .orderedSame { return localized } return displayName } /// Creates a language entry. public init( code: String, modelName: String, displayName: String? = nil, isRTL: Bool = false, usesDenseScript: Bool = false ) { self.code = code self.modelName = modelName self.displayName = displayName ?? modelName self.isRTL = isRTL self.usesDenseScript = usesDenseScript } }