-
Notifications
You must be signed in to change notification settings - Fork 358
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add basic implementation for Caiyun Service Fix CR suggestion Add caiyun service transtype support perf: split caiyun test token to more parts perf: improve caiyun supported langauges dict Update Easydict/Feature/Service/Caiyun/CaiyunService.swift Co-authored-by: Kyle <kyle201817146@gmail.com>
- Loading branch information
Showing
10 changed files
with
240 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,5 @@ | |
#import "MMLog.h" | ||
|
||
#import "EZQueryService.h" | ||
#import "EZConstKey.h" | ||
#import "FWEncryptorAES.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// | ||
// CaiyunResponse.swift | ||
// Easydict | ||
// | ||
// Created by Kyle on 2023/11/24. | ||
// Copyright © 2023 izual. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
struct CaiyunResponse: Codable { | ||
var confidence: Double | ||
var rc: Int | ||
var target: [String] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// | ||
// CaiyunTranslateType.swift | ||
// Easydict | ||
// | ||
// Created by Kyle on 2023/11/24. | ||
// Copyright © 2023 izual. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
struct CaiyunTranslateType: RawRepresentable { | ||
var rawValue: String | ||
|
||
static let unsupported = CaiyunTranslateType(rawValue: "unsupported") | ||
|
||
// Align with the web interface | ||
static func type(from: Language, to: Language) -> CaiyunTranslateType { | ||
if from.isChinese { | ||
guard [Language.english, .japanese, .korean, .spanish, .french, .russian].contains(to) else { | ||
return .unsupported | ||
} | ||
} else if from == .english { | ||
guard [Language.simplifiedChinese, .spanish, .french, .russian].contains(to) else { | ||
return .unsupported | ||
} | ||
} else if from == .japanese { | ||
guard [Language.simplifiedChinese].contains(to) else { | ||
return .unsupported | ||
} | ||
} else if from == .korean { | ||
guard [Language.simplifiedChinese].contains(to) else { | ||
return .unsupported | ||
} | ||
} else if from == .spanish { | ||
guard [Language.simplifiedChinese, .english, .french, .russian].contains(to) else { | ||
return .unsupported | ||
} | ||
} else if from == .french { | ||
guard [Language.simplifiedChinese, .english, .spanish, .russian].contains(to) else { | ||
return .unsupported | ||
} | ||
} else if from == .french { | ||
guard [Language.simplifiedChinese, .english, .spanish, .french].contains(to) else { | ||
return .unsupported | ||
} | ||
} else if from == .auto { | ||
guard [Language.simplifiedChinese, .english, .japanese, .korean, .spanish, .french, .russian].contains(to) else { | ||
return .unsupported | ||
} | ||
} | ||
return CaiyunTranslateType(rawValue: "\(from.caiyunValue)2\(to.caiyunValue)") | ||
} | ||
} | ||
|
||
extension Language { | ||
var isChinese: Bool { | ||
[Language.classicalChinese, .simplifiedChinese, .traditionalChinese].contains(self) | ||
} | ||
|
||
var caiyunValue: String { | ||
switch self { | ||
case .classicalChinese, .simplifiedChinese, .traditionalChinese: return "zh" | ||
case .english: return "en" | ||
case .japanese: return "ja" | ||
case .korean: return "ko" | ||
case .spanish: return "es" | ||
case .french: return "fr" | ||
case .russian: return "ru" | ||
case .auto: return "auto" | ||
default: return "" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters