// // LanguageRepository.swift // SodaLive // // Created by Junie (AI) on 2025/12/16. // import Foundation protocol LanguageRepository { func load() async throws -> LanguageOption? func save(_ option: LanguageOption) async throws } final class UserDefaultsLanguageRepository: LanguageRepository { private let key = "app.language" func load() async throws -> LanguageOption? { try Task.checkCancellation() return await withCheckedContinuation { cont in let value = UserDefaults.standard.string(forKey: key) cont.resume(returning: value.flatMap { LanguageOption(rawValue: $0) }) } } func save(_ option: LanguageOption) async throws { try Task.checkCancellation() return await withCheckedContinuation { cont in UserDefaults.standard.set(option.rawValue, forKey: key) cont.resume() } } }