spiegel-keyman/mac/KeymanSettings/Sources/Persistence/Data/LanguageSource.swift
Shawn Schantz 73ac6d5972
Some checks are pending
Keyman Build Summary / Summarize build status checks (push) Waiting to run
feat(mac): updates for devin.ai review and added tests
2026-05-07 08:13:29 -04:00

37 lines
895 B
Swift

/*
* Keyman is copyright (C) SIL Global. MIT License.
*
* Created by Shawn Schantz on 2025-12-19
*
* Value object for loading a language from kmp.json
*
*/
public struct LanguageSource: Identifiable, Decodable, Hashable, Equatable {
let name: String?
public let id: String
enum CodingKeys: String, CodingKey {
case name
case id
}
public init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
self.name = try container.decodeIfPresent(String.self, forKey: .name)
let id = try container.decodeIfPresent(String.self, forKey: .id)
guard let validId = id, !validId.isEmpty else {
throw DecodingError.dataCorruptedError(
forKey: .id,
in: container,
debugDescription: "Language.id is required and cannot be empty."
)
}
self.id = validId
}
}