spiegel-keyman/mac/KeymanSettings/Sources/Persistence/Data/LanguageSource.swift
Shawn Schantz 5cd8112532 feat(mac): add loading of kmp files
currently reads from the old data directory
UI is for testing only
2026-03-04 16:55:34 -05:00

37 lines
911 B
Swift

/*
* Keyman is copyright (C) SIL Global. MIT License.
*
* Created by Shawn Schantz on 2025-12-19
*
* Value object that describes a language as loaded from a .KMP file
*
*/
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
}
}