Skip to content

Commit

Permalink
fix: change OpenAI UsageStatus option
Browse files Browse the repository at this point in the history
  • Loading branch information
phlpsong committed Feb 3, 2024
1 parent 4d14744 commit 633ab52
Show file tree
Hide file tree
Showing 4 changed files with 164 additions and 77 deletions.
142 changes: 95 additions & 47 deletions Easydict/App/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -2460,98 +2460,114 @@
}
}
},
"service.configuration.deepl.translation.title" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "API Usage Priority"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "API 使用优先级"
}
}
}
},
"service.configuration.deepl.web_first.title" : {
"service.configuration.deepl.authkey_first.title" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Web API first"
"value" : "Auth Key First"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "优先使用 Web API"
"value" : "优先使用 Auth Key"
}
}
}
},
"service.configuration.deepl.authkey_first.title" : {
"service.configuration.deepl.authkey_only.title" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Auth Key First"
"value" : "Auth Key Only"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "优先使用 Auth Key"
"value" : "仅使用 Auth Key"
}
}
}
},
"service.configuration.deepl.authkey_only.title" : {
"service.configuration.deepl.endpoint.placeholder" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Auth Key Only"
"value" : "https://api-free.deepl.com/v2/translate"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "仅使用 Auth Key"
"value" : "https://api-free.deepl.com/v2/translate"
}
}
}
},
"service.configuration.deepl.endpoint.placeholder" : {
"service.configuration.deepl.endpoint.title" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "https://api-free.deepl.com/v2/translate"
"value" : "API Endpoint"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "https://api-free.deepl.com/v2/translate"
"value" : "完整接口地址"
}
}
}
},
"service.configuration.deepl.endpoint.title" : {
"service.configuration.deepl.translation.title" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "API Endpoint"
"value" : "API Usage Priority"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "完整接口地址"
"value" : "API 使用优先级"
}
}
}
},
"service.configuration.deepl.web_first.title" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Web API first"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "优先使用 Web API"
}
}
}
},
"service.configuration.gemini.api_key.title" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "API Key"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "API Key"
}
}
}
Expand Down Expand Up @@ -2716,82 +2732,114 @@
}
}
},
"service.configuration.openai.usage_status.title" : {
"service.configuration.openai.usage_status_always_off.title" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Usage Status"
"value" : "Always Off"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "使用状态"
"value" : "始终关闭"
}
}
}
},
"service.configuration.reset" : {
"service.configuration.openai.usage_status_always_on.title" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Reset"
"value" : "Always On"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "重置"
"value" : "始终打开"
}
}
}
},
"service.configuration.tencent.secret_id.title" : {
"service.configuration.openai.usage_status_default.title" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Secret Id"
"value" : "Default"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "Secret Id"
"value" : "默认"
}
}
}
},
"service.configuration.tencent.secret_key.title" : {
"service.configuration.openai.usage_status.title" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Secret Key"
"value" : "Usage Status"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "Secret Key"
"value" : "使用状态"
}
}
}
},
"service.configuration.gemini.api_key.title" : {
"service.configuration.reset" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "API Key"
"value" : "Reset"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "API Key"
"value" : "重置"
}
}
}
},
"service.configuration.tencent.secret_id.title" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Secret Id"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "Secret Id"
}
}
}
},
"service.configuration.tencent.secret_key.title" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Secret Key"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "Secret Key"
}
}
}
Expand Down Expand Up @@ -3975,4 +4023,4 @@
}
},
"version" : "1.0"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,6 @@
import Foundation
import SwiftUI

protocol EnumLocalizedStringConvertible {
var title: String { get }
}

enum OpenAIModels: String, CaseIterable, Identifiable {
var id: Self {
self
}

case gpt3_5_turbo = "gpt-3.5-turbo"
case gpt3_5_turbo_1106 = "gpt-3.5-turbo-1106"
case gpt4
case gpt4_32k = "gpt-4-32k"
}

extension OpenAIModels: EnumLocalizedStringConvertible {
var title: String {
rawValue
}
}

@available(macOS 13.0, *)
extension EZOpenAIService: ConfigurableService {
func configurationListItems() -> some View {
Expand Down Expand Up @@ -64,9 +43,66 @@ extension EZOpenAIService: ConfigurableService {
titleKey: "service.configuration.openai.dictionary.title",
key: .openAIDictionary
)
ServiceConfigurationToggleCell(
ServiceConfigurationPickerCell(
titleKey: "service.configuration.openai.usage_status.title",
key: .openAIServiceUsageStatus
key: .openAIServiceUsageStatus,
values: OpenAIUsageStats.allCases
)
}
}
}

protocol EnumLocalizedStringConvertible {
var title: String { get }
}

enum OpenAIModels: String, CaseIterable, Identifiable {
var id: Self {
self
}

case gpt3_5_turbo = "gpt-3.5-turbo"
case gpt3_5_turbo_1106 = "gpt-3.5-turbo-1106"
case gpt4
case gpt4_32k = "gpt-4-32k"
}

extension OpenAIModels: EnumLocalizedStringConvertible {
var title: String {
rawValue
}
}

enum OpenAIUsageStats: String, CaseIterable, Identifiable {
var id: Self {
self
}

case `default` = "0"
case alwaysOff = "1"
case alwaysOn = "2"
}

extension OpenAIUsageStats: EnumLocalizedStringConvertible {
var title: String {
switch self {
case .default:
return NSLocalizedString(
"service.configuration.openai.usage_status_default.title",
bundle: .main,
comment: ""
)
case .alwaysOff:
return NSLocalizedString(
"service.configuration.openai.usage_status_always_off.title",
bundle: .main,
comment: ""
)
case .alwaysOn:
return NSLocalizedString(
"service.configuration.openai.usage_status_always_on.title",
bundle: .main,
comment: ""
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class ConfigurationToggleViewModel: ObservableObject {
struct ServiceConfigurationToggleCell: View {
@Default var value: String
let titleKey: LocalizedStringKey

@ObservedObject var viewModel = ConfigurationToggleViewModel()

init(titleKey: LocalizedStringKey, key: Defaults.Key<String>) {
Expand Down
Loading

0 comments on commit 633ab52

Please sign in to comment.