damus

nostr ios client
git clone git://jb55.com/damus
Log | Files | Refs | README | LICENSE

DeepLPlan.swift (1131B)


      1 //
      2 //  DeepLPlan.swift
      3 //  damus
      4 //
      5 //  Created by Terry Yiu on 2/3/23.
      6 //
      7 
      8 import Foundation
      9 
     10 enum DeepLPlan: String, CaseIterable, Identifiable, StringCodable {
     11     init?(from string: String) {
     12         guard let dl = DeepLPlan(rawValue: string) else {
     13             return nil
     14         }
     15         
     16         self = dl
     17     }
     18     
     19     func to_string() -> String {
     20         return self.rawValue
     21     }
     22     
     23     var id: String { self.rawValue }
     24 
     25     struct Model: Identifiable, Hashable {
     26         var id: String { self.tag }
     27         var tag: String
     28         var displayName: String
     29         var url: String
     30     }
     31 
     32     case free
     33     case pro
     34 
     35     var model: Model {
     36         switch self {
     37         case .free:
     38             return .init(tag: self.rawValue, displayName: NSLocalizedString("Free", comment: "Dropdown option for selecting Free plan for DeepL translation service."), url: "https://api-free.deepl.com")
     39         case .pro:
     40             return .init(tag: self.rawValue, displayName: NSLocalizedString("Pro", comment: "Dropdown option for selecting Pro plan for DeepL translation service."), url: "https://api.deepl.com")
     41         }
     42     }
     43 }