Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: make configuration defaultTTSServiceType get rid of limitation of no more than macOS 13 #336

Merged
merged 2 commits into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Easydict/NewApp/Configuration/Configuration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ extension Defaults.Keys {
static let autoCopySelectedText = Key<Bool>("EZConfiguration_kAutoCopySelectedTextKey", default: false)
static let autoCopyFirstTranslatedText = Key<Bool>("EZConfiguration_kAutoCopyFirstTranslatedTextKey", default: false)
static let languageDetectOptimize = Key<EZLanguageDetectOptimize>("EZConfiguration_kLanguageDetectOptimizeTypeKey", default: EZLanguageDetectOptimize.none)
@available(macOS 13, *)
static let defaultTTSServiceType = Key<TTSServiceType>("EZConfiguration_kDefaultTTSServiceTypeKey", default: TTSServiceType.youdao)
static let showGoogleQuickLink = Key<Bool>("EZConfiguration_kShowGoogleLinkKey", default: true)
static let showEudicQuickLink = Key<Bool>("EZConfiguration_kShowEudicLinkKey", default: true)
Expand Down
17 changes: 9 additions & 8 deletions Easydict/NewApp/Model/TTSServiceType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,16 @@
import Defaults
import Foundation

enum TTSServiceType: String, CaseIterable {
case youdao
case bing
case google
case baidu
case apple
}

@available(macOS 13, *)
enum TTSServiceType: String, CaseIterable, CustomLocalizedStringResourceConvertible {
extension TTSServiceType: CustomLocalizedStringResourceConvertible {
var localizedStringResource: LocalizedStringResource {
switch self {
case .youdao:
Expand All @@ -25,15 +33,8 @@ enum TTSServiceType: String, CaseIterable, CustomLocalizedStringResourceConverti
"setting.tts_service.options.apple"
}
}

case youdao
case bing
case google
case baidu
case apple
}

@available(macOS 13, *)
extension TTSServiceType: Defaults.Serializable {
// while in the future, ServiceType was deleted, then you can safely delete this struct and `bridge`
struct TTSServiceTypeBridge: Defaults.Bridge {
Expand Down
Loading