diff --git a/Easydict/App/Localizable.xcstrings b/Easydict/App/Localizable.xcstrings index 2263aea51..e6d0d197e 100644 --- a/Easydict/App/Localizable.xcstrings +++ b/Easydict/App/Localizable.xcstrings @@ -414,6 +414,17 @@ } } }, + "caiyun_translate" : { + "comment" : "The name of Caiyun Translate", + "localizations" : { + "zh-Hans" : { + "stringUnit" : { + "state" : "translated", + "value" : "彩云小译" + } + } + } + }, "cancel" : { "localizations" : { "en" : { diff --git a/Easydict/Feature/Service/Caiyun/CaiyunService.swift b/Easydict/Feature/Service/Caiyun/CaiyunService.swift index 6a44e2c5a..c81a0ba0b 100644 --- a/Easydict/Feature/Service/Caiyun/CaiyunService.swift +++ b/Easydict/Feature/Service/Caiyun/CaiyunService.swift @@ -11,4 +11,34 @@ import Foundation @objc(EZCaiyunService) public final class CaiyunService: QueryService { + public override func serviceType() -> ServiceType { + .caiyun + } + + public override func link() -> String? { + "https://fanyi.caiyunapp.com" + } + + public override func name() -> String { + NSLocalizedString("caiyun_translate", comment: "The name of Caiyun Translate") + } + + public override func supportLanguagesDictionary() -> MMOrderedDictionary { + // TODO: Replace MMOrderedDictionary in the API + let orderedDict = MMOrderedDictionary() + orderedDict.setObject(Language.auto.rawValue as NSString, forKey: "auto" as NSString) + orderedDict.setObject(Language.simplifiedChinese.rawValue as NSString, forKey: "zh" as NSString) + orderedDict.setObject(Language.english.rawValue as NSString, forKey: "en" as NSString) + orderedDict.setObject(Language.japanese.rawValue as NSString, forKey: "ja" as NSString) + return orderedDict + } + + public override func ocr(_ queryModel: EZQueryModel) async throws -> EZOCRResult { + NSLog("Caiyun Translate does not support OCR") + throw QueryServiceError.notSupported + } +} + +enum QueryServiceError: Error { + case notSupported } diff --git a/Easydict/Feature/Service/Language/EZLanguageModel.h b/Easydict/Feature/Service/Language/EZLanguageModel.h index e16d446a5..7152182a4 100644 --- a/Easydict/Feature/Service/Language/EZLanguageModel.h +++ b/Easydict/Feature/Service/Language/EZLanguageModel.h @@ -12,7 +12,7 @@ NS_ASSUME_NONNULL_BEGIN // Refer Apple NLLanguage. -typedef NSString *EZLanguage NS_STRING_ENUM; +typedef NSString *EZLanguage NS_STRING_ENUM NS_SWIFT_NAME(Language); // 目前总计支持 49 种语言:简体中文,繁体中文,文言文,英语,日语,韩语,法语,西班牙语,葡萄牙语,意大利语,德语,俄语,阿拉伯语,瑞典语,罗马尼亚语,泰语,斯洛伐克语,荷兰语,匈牙利语,希腊语,丹麦语,芬兰语,波兰语,捷克语,土耳其语,立陶宛语,拉脱维亚语,乌克兰语,保加利亚语,印尼语,马来语,斯洛文尼亚语,爱沙尼亚语,越南语,波斯语,印地语,泰卢固语,泰米尔语,乌尔都语,菲律宾语,高棉语,老挝语,孟加拉语,缅甸语,挪威语,塞尔维亚语,克罗地亚语,蒙古语,希伯来语。 diff --git a/Easydict/Feature/Service/Model/EZEnumTypes.h b/Easydict/Feature/Service/Model/EZEnumTypes.h index e60b6dec6..b759bfbcd 100644 --- a/Easydict/Feature/Service/Model/EZEnumTypes.h +++ b/Easydict/Feature/Service/Model/EZEnumTypes.h @@ -29,7 +29,7 @@ typedef NS_ENUM(NSUInteger, EZShowWindowPosition) { FOUNDATION_EXPORT NSString *const EZServiceTypeKey; -typedef NSString *EZServiceType NS_STRING_ENUM; +typedef NSString *EZServiceType NS_STRING_ENUM NS_SWIFT_NAME(ServiceType); FOUNDATION_EXPORT EZServiceType const EZServiceTypeGoogle; FOUNDATION_EXPORT EZServiceType const EZServiceTypeBaidu; FOUNDATION_EXPORT EZServiceType const EZServiceTypeYoudao;