import Foundation /// A source-language to target-language rule. The mother tongue is the default when no rule matches. public struct LanguageRoute: Codable, Sendable, Equatable, Hashable, Identifiable { /// The canonical BCP-47 source code. public var source: String /// The canonical BCP-47 target code. public var target: String /// The source code is unique in the rule table. public var id: String { source } /// Creates a route from canonical codes. public init(source: String, target: String) { self.source = source self.target = target } /// Creates a route from catalogue entries. public init(source: ModelLanguage, target: ModelLanguage) { self.init(source: source.code, target: target.code) } /// The catalogue entry for the source, or nil when the code is unknown. public var sourceLanguage: ModelLanguage? { HyMT3Languages.resolve(source) } /// The catalogue entry for the target, or nil when the code is unknown. public var targetLanguage: ModelLanguage? { HyMT3Languages.resolve(target) } }