From 7fa5c42f24fcd529dd689880a5ee7d7eaea47e0f Mon Sep 17 00:00:00 2001 From: Jerry Date: Tue, 2 Jan 2024 21:23:09 -0800 Subject: [PATCH] fix: missing GeminiTranslateType file --- Easydict.xcodeproj/project.pbxproj | 36 +++--- .../Service/Gemini/GeminiTranslateType.swift | 122 ++++++++++++++++++ 2 files changed, 140 insertions(+), 18 deletions(-) create mode 100644 Easydict/Feature/Service/Gemini/GeminiTranslateType.swift diff --git a/Easydict.xcodeproj/project.pbxproj b/Easydict.xcodeproj/project.pbxproj index 476df1056..98768c615 100644 --- a/Easydict.xcodeproj/project.pbxproj +++ b/Easydict.xcodeproj/project.pbxproj @@ -11,11 +11,11 @@ 03008B2B2940D3230062B821 /* EZDeepLTranslate.m in Sources */ = {isa = PBXBuildFile; fileRef = 03008B2A2940D3230062B821 /* EZDeepLTranslate.m */; }; 03008B2E2941956D0062B821 /* EZURLSchemeHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = 03008B2D2941956D0062B821 /* EZURLSchemeHandler.m */; }; 03008B3F29444B0A0062B821 /* NSView+EZAnimatedHidden.m in Sources */ = {isa = PBXBuildFile; fileRef = 03008B3E29444B0A0062B821 /* NSView+EZAnimatedHidden.m */; }; + 03022F192B3591AE00B63209 /* GoogleGenerativeAI in Frameworks */ = {isa = PBXBuildFile; productRef = 03022F182B3591AE00B63209 /* GoogleGenerativeAI */; }; 03022F1C2B35DEBA00B63209 /* Hue in Frameworks */ = {isa = PBXBuildFile; productRef = 03022F1B2B35DEBA00B63209 /* Hue */; }; 03022F1F2B36CF3100B63209 /* SwiftShell in Frameworks */ = {isa = PBXBuildFile; productRef = 03022F1E2B36CF3100B63209 /* SwiftShell */; }; 03022F222B36D1A400B63209 /* SnapKit in Frameworks */ = {isa = PBXBuildFile; productRef = 03022F212B36D1A400B63209 /* SnapKit */; }; 03022F312B370B7100B63209 /* EasydictSwiftTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03022F302B370B7100B63209 /* EasydictSwiftTests.swift */; }; - 03022F192B3591AE00B63209 /* GoogleGenerativeAI in Frameworks */ = {isa = PBXBuildFile; productRef = 03022F182B3591AE00B63209 /* GoogleGenerativeAI */; }; 030570E22ADB919900C9905E /* EZAppleScriptManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 030570E12ADB919900C9905E /* EZAppleScriptManager.m */; }; 0309E1ED292B439A00AFB76A /* EZTextView.m in Sources */ = {isa = PBXBuildFile; fileRef = 0309E1EC292B439A00AFB76A /* EZTextView.m */; }; 0309E1F0292B4A5E00AFB76A /* NSView+EZGetViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 0309E1EF292B4A5E00AFB76A /* NSView+EZGetViewController.m */; }; @@ -254,7 +254,7 @@ A0B65CA0F31AC8ECFB8347CC /* Pods_EasydictTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 378E73A7EA8FC8FB9C975A63 /* Pods_EasydictTests.framework */; }; B87AC7E36367075BA5D13234 /* Pods_Easydict.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6372B33DFF803C7096A82250 /* Pods_Easydict.framework */; }; C415C0AD2B450D4800A9D231 /* GeminiService.swift in Sources */ = {isa = PBXBuildFile; fileRef = C415C0AC2B450D4800A9D231 /* GeminiService.swift */; }; - C415C0AF2B450F9200A9D231 /* GeminiTranslateType.swift in Sources */ = {isa = PBXBuildFile; fileRef = C415C0AE2B450F9200A9D231 /* GeminiTranslateType.swift */; }; + C415C0B22B45258600A9D231 /* GeminiTranslateType.swift in Sources */ = {isa = PBXBuildFile; fileRef = C415C0B12B45258600A9D231 /* GeminiTranslateType.swift */; }; C4DD01E92B12B3C80025EE8E /* TencentService.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4DD01E82B12B3C80025EE8E /* TencentService.swift */; }; C4DD01EB2B12BA250025EE8E /* TencentResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4DD01EA2B12BA250025EE8E /* TencentResponse.swift */; }; C4DD01ED2B12BE9B0025EE8E /* TencentTranslateType.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4DD01EC2B12BE9B0025EE8E /* TencentTranslateType.swift */; }; @@ -731,7 +731,7 @@ 9672D7D12B4008B40023B8FB /* MASShortcutBinder+EZMASShortcutBinder.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "MASShortcutBinder+EZMASShortcutBinder.m"; sourceTree = ""; }; A230E9A2358C7FBC7FB26189 /* Pods-EasydictTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-EasydictTests.debug.xcconfig"; path = "Target Support Files/Pods-EasydictTests/Pods-EasydictTests.debug.xcconfig"; sourceTree = ""; }; C415C0AC2B450D4800A9D231 /* GeminiService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GeminiService.swift; sourceTree = ""; }; - C415C0AE2B450F9200A9D231 /* GeminiTranslateType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = GeminiTranslateType.swift; path = ../../../../../../../GeminiTranslateType.swift; sourceTree = ""; }; + C415C0B12B45258600A9D231 /* GeminiTranslateType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GeminiTranslateType.swift; sourceTree = ""; }; C4DD01E82B12B3C80025EE8E /* TencentService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TencentService.swift; sourceTree = ""; }; C4DD01EA2B12BA250025EE8E /* TencentResponse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TencentResponse.swift; sourceTree = ""; }; C4DD01EC2B12BE9B0025EE8E /* TencentTranslateType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TencentTranslateType.swift; sourceTree = ""; }; @@ -2099,7 +2099,7 @@ isa = PBXGroup; children = ( C415C0AC2B450D4800A9D231 /* GeminiService.swift */, - C415C0AE2B450F9200A9D231 /* GeminiTranslateType.swift */, + C415C0B12B45258600A9D231 /* GeminiTranslateType.swift */, ); path = Gemini; sourceTree = ""; @@ -2550,7 +2550,6 @@ 03542A522937B69200C34C33 /* EZYoudaoTranslateResponse.m in Sources */, 03B0230129231FA6001C7E63 /* EZQueryView.m in Sources */, 03542A3D2937AF4F00C34C33 /* EZQueryResult.m in Sources */, - C415C0AF2B450F9200A9D231 /* GeminiTranslateType.swift in Sources */, 03262C1F29EF8EE500EFECA0 /* EZPrivacyViewController.m in Sources */, 9672D7D22B4008B40023B8FB /* MASShortcutBinder+EZMASShortcutBinder.m in Sources */, 03BDA7BF2A26DA280079D04F /* NSScanner+EscapedScanning.m in Sources */, @@ -2697,6 +2696,7 @@ 6220AD5B2A82812300BBFB52 /* EZBingService.m in Sources */, 039F5508294B6E29004AB940 /* EZAboutViewController.m in Sources */, 03D8A6592A42A1A300D9A968 /* EZAppModel.m in Sources */, + C415C0B22B45258600A9D231 /* GeminiTranslateType.swift in Sources */, 036E7D7B293F4FC8002675DF /* EZOpenLinkButton.m in Sources */, 276742092B3DC230002A2C75 /* AboutTab.swift in Sources */, 03008B2E2941956D0062B821 /* EZURLSchemeHandler.m in Sources */, @@ -3167,6 +3167,14 @@ /* End XCConfigurationList section */ /* Begin XCRemoteSwiftPackageReference section */ + 03022F172B3591AE00B63209 /* XCRemoteSwiftPackageReference "generative-ai-swift" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/google/generative-ai-swift"; + requirement = { + kind = upToNextMajorVersion; + minimumVersion = 0.4.4; + }; + }; 03022F1A2B35DEBA00B63209 /* XCRemoteSwiftPackageReference "Hue" */ = { isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/zenangst/Hue"; @@ -3245,14 +3253,6 @@ requirement = { kind = upToNextMajorVersion; minimumVersion = 10.45.2; - }; - }; - 03022F172B3591AE00B63209 /* XCRemoteSwiftPackageReference "generative-ai-swift" */ = { - isa = XCRemoteSwiftPackageReference; - repositoryURL = "https://github.com/google/generative-ai-swift"; - requirement = { - kind = upToNextMajorVersion; - minimumVersion = 0.4.4; }; }; 03FD68B92B1DC59600FD388E /* XCRemoteSwiftPackageReference "CryptoSwift" */ = { @@ -3274,6 +3274,11 @@ /* End XCRemoteSwiftPackageReference section */ /* Begin XCSwiftPackageProductDependency section */ + 03022F182B3591AE00B63209 /* GoogleGenerativeAI */ = { + isa = XCSwiftPackageProductDependency; + package = 03022F172B3591AE00B63209 /* XCRemoteSwiftPackageReference "generative-ai-swift" */; + productName = GoogleGenerativeAI; + }; 03022F1B2B35DEBA00B63209 /* Hue */ = { isa = XCSwiftPackageProductDependency; package = 03022F1A2B35DEBA00B63209 /* XCRemoteSwiftPackageReference "Hue" */; @@ -3338,11 +3343,6 @@ isa = XCSwiftPackageProductDependency; package = 03CF27FC2B3DA7D500E19B57 /* XCRemoteSwiftPackageReference "realm-swift" */; productName = RealmSwift; - }; - 03022F182B3591AE00B63209 /* GoogleGenerativeAI */ = { - isa = XCSwiftPackageProductDependency; - package = 03022F172B3591AE00B63209 /* XCRemoteSwiftPackageReference "generative-ai-swift" */; - productName = GoogleGenerativeAI; }; 03FD68BA2B1DC59600FD388E /* CryptoSwift */ = { isa = XCSwiftPackageProductDependency; diff --git a/Easydict/Feature/Service/Gemini/GeminiTranslateType.swift b/Easydict/Feature/Service/Gemini/GeminiTranslateType.swift new file mode 100644 index 000000000..aaa969ff1 --- /dev/null +++ b/Easydict/Feature/Service/Gemini/GeminiTranslateType.swift @@ -0,0 +1,122 @@ +// +// GeminiTranslateType.swift +// Easydict +// +// Created by Jerry on 2024-01-02. +// Copyright © 2024 izual. All rights reserved. +// + +import Foundation + +struct GeminiTranslateType: RawRepresentable { + var rawValue: String + + static let unsupported = GeminiTranslateType(rawValue: "unsupported") + + // https://ai.google.dev/available_regions + static let supportedTypes: [Language: [Language]] = [ + .arabic: [.arabic, .bengali, .bulgarian, .simplifiedChinese, .traditionalChinese, .croatian, .czech, .danish, .dutch, .english, .estonian, .finnish, .french, .german, .greek, .hebrew, .hindi, .hungarian, .indonesian, .italian, .japanese, .korean, .latvian, .lithuanian, .norwegian, .polish, .portuguese, .romanian, .russian, .serbian, .slovak, .slovenian, .spanish, .swedish, .thai, .turkish, .ukrainian, .vietnamese], + .bengali: [.arabic, .bengali, .bulgarian, .simplifiedChinese, .traditionalChinese, .croatian, .czech, .danish, .dutch, .english, .estonian, .finnish, .french, .german, .greek, .hebrew, .hindi, .hungarian, .indonesian, .italian, .japanese, .korean, .latvian, .lithuanian, .norwegian, .polish, .portuguese, .romanian, .russian, .serbian, .slovak, .slovenian, .spanish, .swedish, .thai, .turkish, .ukrainian, .vietnamese], + .bulgarian: [.arabic, .bengali, .bulgarian, .simplifiedChinese, .traditionalChinese, .croatian, .czech, .danish, .dutch, .english, .estonian, .finnish, .french, .german, .greek, .hebrew, .hindi, .hungarian, .indonesian, .italian, .japanese, .korean, .latvian, .lithuanian, .norwegian, .polish, .portuguese, .romanian, .russian, .serbian, .slovak, .slovenian, .spanish, .swedish, .thai, .turkish, .ukrainian, .vietnamese], + .simplifiedChinese: [.arabic, .bengali, .bulgarian, .simplifiedChinese, .traditionalChinese, .croatian, .czech, .danish, .dutch, .english, .estonian, .finnish, .french, .german, .greek, .hebrew, .hindi, .hungarian, .indonesian, .italian, .japanese, .korean, .latvian, .lithuanian, .norwegian, .polish, .portuguese, .romanian, .russian, .serbian, .slovak, .slovenian, .spanish, .swedish, .thai, .turkish, .ukrainian, .vietnamese], + .traditionalChinese: [.arabic, .bengali, .bulgarian, .simplifiedChinese, .traditionalChinese, .croatian, .czech, .danish, .dutch, .english, .estonian, .finnish, .french, .german, .greek, .hebrew, .hindi, .hungarian, .indonesian, .italian, .japanese, .korean, .latvian, .lithuanian, .norwegian, .polish, .portuguese, .romanian, .russian, .serbian, .slovak, .slovenian, .spanish, .swedish, .thai, .turkish, .ukrainian, .vietnamese], + .croatian: [.arabic, .bengali, .bulgarian, .simplifiedChinese, .traditionalChinese, .croatian, .czech, .danish, .dutch, .english, .estonian, .finnish, .french, .german, .greek, .hebrew, .hindi, .hungarian, .indonesian, .italian, .japanese, .korean, .latvian, .lithuanian, .norwegian, .polish, .portuguese, .romanian, .russian, .serbian, .slovak, .slovenian, .spanish, .swedish, .thai, .turkish, .ukrainian, .vietnamese], + .czech: [.arabic, .bengali, .bulgarian, .simplifiedChinese, .traditionalChinese, .croatian, .czech, .danish, .dutch, .english, .estonian, .finnish, .french, .german, .greek, .hebrew, .hindi, .hungarian, .indonesian, .italian, .japanese, .korean, .latvian, .lithuanian, .norwegian, .polish, .portuguese, .romanian, .russian, .serbian, .slovak, .slovenian, .spanish, .swedish, .thai, .turkish, .ukrainian, .vietnamese], + .danish: [.arabic, .bengali, .bulgarian, .simplifiedChinese, .traditionalChinese, .croatian, .czech, .danish, .dutch, .english, .estonian, .finnish, .french, .german, .greek, .hebrew, .hindi, .hungarian, .indonesian, .italian, .japanese, .korean, .latvian, .lithuanian, .norwegian, .polish, .portuguese, .romanian, .russian, .serbian, .slovak, .slovenian, .spanish, .swedish, .thai, .turkish, .ukrainian, .vietnamese], + .dutch: [.arabic, .bengali, .bulgarian, .simplifiedChinese, .traditionalChinese, .croatian, .czech, .danish, .dutch, .english, .estonian, .finnish, .french, .german, .greek, .hebrew, .hindi, .hungarian, .indonesian, .italian, .japanese, .korean, .latvian, .lithuanian, .norwegian, .polish, .portuguese, .romanian, .russian, .serbian, .slovak, .slovenian, .spanish, .swedish, .thai, .turkish, .ukrainian, .vietnamese], + .english: [.arabic, .bengali, .bulgarian, .simplifiedChinese, .traditionalChinese, .croatian, .czech, .danish, .dutch, .english, .estonian, .finnish, .french, .german, .greek, .hebrew, .hindi, .hungarian, .indonesian, .italian, .japanese, .korean, .latvian, .lithuanian, .norwegian, .polish, .portuguese, .romanian, .russian, .serbian, .slovak, .slovenian, .spanish, .swedish, .thai, .turkish, .ukrainian, .vietnamese], + .estonian: [.arabic, .bengali, .bulgarian, .simplifiedChinese, .traditionalChinese, .croatian, .czech, .danish, .dutch, .english, .estonian, .finnish, .french, .german, .greek, .hebrew, .hindi, .hungarian, .indonesian, .italian, .japanese, .korean, .latvian, .lithuanian, .norwegian, .polish, .portuguese, .romanian, .russian, .serbian, .slovak, .slovenian, .spanish, .swedish, .thai, .turkish, .ukrainian, .vietnamese], + .finnish: [.arabic, .bengali, .bulgarian, .simplifiedChinese, .traditionalChinese, .croatian, .czech, .danish, .dutch, .english, .estonian, .finnish, .french, .german, .greek, .hebrew, .hindi, .hungarian, .indonesian, .italian, .japanese, .korean, .latvian, .lithuanian, .norwegian, .polish, .portuguese, .romanian, .russian, .serbian, .slovak, .slovenian, .spanish, .swedish, .thai, .turkish, .ukrainian, .vietnamese], + .french: [.arabic, .bengali, .bulgarian, .simplifiedChinese, .traditionalChinese, .croatian, .czech, .danish, .dutch, .english, .estonian, .finnish, .french, .german, .greek, .hebrew, .hindi, .hungarian, .indonesian, .italian, .japanese, .korean, .latvian, .lithuanian, .norwegian, .polish, .portuguese, .romanian, .russian, .serbian, .slovak, .slovenian, .spanish, .swedish, .thai, .turkish, .ukrainian, .vietnamese], + .german: [.arabic, .bengali, .bulgarian, .simplifiedChinese, .traditionalChinese, .croatian, .czech, .danish, .dutch, .english, .estonian, .finnish, .french, .german, .greek, .hebrew, .hindi, .hungarian, .indonesian, .italian, .japanese, .korean, .latvian, .lithuanian, .norwegian, .polish, .portuguese, .romanian, .russian, .serbian, .slovak, .slovenian, .spanish, .swedish, .thai, .turkish, .ukrainian, .vietnamese], + .greek: [.arabic, .bengali, .bulgarian, .simplifiedChinese, .traditionalChinese, .croatian, .czech, .danish, .dutch, .english, .estonian, .finnish, .french, .german, .greek, .hebrew, .hindi, .hungarian, .indonesian, .italian, .japanese, .korean, .latvian, .lithuanian, .norwegian, .polish, .portuguese, .romanian, .russian, .serbian, .slovak, .slovenian, .spanish, .swedish, .thai, .turkish, .ukrainian, .vietnamese], + .hebrew: [.arabic, .bengali, .bulgarian, .simplifiedChinese, .traditionalChinese, .croatian, .czech, .danish, .dutch, .english, .estonian, .finnish, .french, .german, .greek, .hebrew, .hindi, .hungarian, .indonesian, .italian, .japanese, .korean, .latvian, .lithuanian, .norwegian, .polish, .portuguese, .romanian, .russian, .serbian, .slovak, .slovenian, .spanish, .swedish, .thai, .turkish, .ukrainian, .vietnamese], + .hindi: [.arabic, .bengali, .bulgarian, .simplifiedChinese, .traditionalChinese, .croatian, .czech, .danish, .dutch, .english, .estonian, .finnish, .french, .german, .greek, .hebrew, .hindi, .hungarian, .indonesian, .italian, .japanese, .korean, .latvian, .lithuanian, .norwegian, .polish, .portuguese, .romanian, .russian, .serbian, .slovak, .slovenian, .spanish, .swedish, .thai, .turkish, .ukrainian, .vietnamese], + .hungarian: [.arabic, .bengali, .bulgarian, .simplifiedChinese, .traditionalChinese, .croatian, .czech, .danish, .dutch, .english, .estonian, .finnish, .french, .german, .greek, .hebrew, .hindi, .hungarian, .indonesian, .italian, .japanese, .korean, .latvian, .lithuanian, .norwegian, .polish, .portuguese, .romanian, .russian, .serbian, .slovak, .slovenian, .spanish, .swedish, .thai, .turkish, .ukrainian, .vietnamese], + .indonesian: [.arabic, .bengali, .bulgarian, .simplifiedChinese, .traditionalChinese, .croatian, .czech, .danish, .dutch, .english, .estonian, .finnish, .french, .german, .greek, .hebrew, .hindi, .hungarian, .indonesian, .italian, .japanese, .korean, .latvian, .lithuanian, .norwegian, .polish, .portuguese, .romanian, .russian, .serbian, .slovak, .slovenian, .spanish, .swedish, .thai, .turkish, .ukrainian, .vietnamese], + .italian: [.arabic, .bengali, .bulgarian, .simplifiedChinese, .traditionalChinese, .croatian, .czech, .danish, .dutch, .english, .estonian, .finnish, .french, .german, .greek, .hebrew, .hindi, .hungarian, .indonesian, .italian, .japanese, .korean, .latvian, .lithuanian, .norwegian, .polish, .portuguese, .romanian, .russian, .serbian, .slovak, .slovenian, .spanish, .swedish, .thai, .turkish, .ukrainian, .vietnamese], + .japanese: [.arabic, .bengali, .bulgarian, .simplifiedChinese, .traditionalChinese, .croatian, .czech, .danish, .dutch, .english, .estonian, .finnish, .french, .german, .greek, .hebrew, .hindi, .hungarian, .indonesian, .italian, .japanese, .korean, .latvian, .lithuanian, .norwegian, .polish, .portuguese, .romanian, .russian, .serbian, .slovak, .slovenian, .spanish, .swedish, .thai, .turkish, .ukrainian, .vietnamese], + .korean: [.arabic, .bengali, .bulgarian, .simplifiedChinese, .traditionalChinese, .croatian, .czech, .danish, .dutch, .english, .estonian, .finnish, .french, .german, .greek, .hebrew, .hindi, .hungarian, .indonesian, .italian, .japanese, .korean, .latvian, .lithuanian, .norwegian, .polish, .portuguese, .romanian, .russian, .serbian, .slovak, .slovenian, .spanish, .swedish, .thai, .turkish, .ukrainian, .vietnamese], + .latvian: [.arabic, .bengali, .bulgarian, .simplifiedChinese, .traditionalChinese, .croatian, .czech, .danish, .dutch, .english, .estonian, .finnish, .french, .german, .greek, .hebrew, .hindi, .hungarian, .indonesian, .italian, .japanese, .korean, .latvian, .lithuanian, .norwegian, .polish, .portuguese, .romanian, .russian, .serbian, .slovak, .slovenian, .spanish, .swedish, .thai, .turkish, .ukrainian, .vietnamese], + .lithuanian: [.arabic, .bengali, .bulgarian, .simplifiedChinese, .traditionalChinese, .croatian, .czech, .danish, .dutch, .english, .estonian, .finnish, .french, .german, .greek, .hebrew, .hindi, .hungarian, .indonesian, .italian, .japanese, .korean, .latvian, .lithuanian, .norwegian, .polish, .portuguese, .romanian, .russian, .serbian, .slovak, .slovenian, .spanish, .swedish, .thai, .turkish, .ukrainian, .vietnamese], + .norwegian: [.arabic, .bengali, .bulgarian, .simplifiedChinese, .traditionalChinese, .croatian, .czech, .danish, .dutch, .english, .estonian, .finnish, .french, .german, .greek, .hebrew, .hindi, .hungarian, .indonesian, .italian, .japanese, .korean, .latvian, .lithuanian, .norwegian, .polish, .portuguese, .romanian, .russian, .serbian, .slovak, .slovenian, .spanish, .swedish, .thai, .turkish, .ukrainian, .vietnamese], + .polish: [.arabic, .bengali, .bulgarian, .simplifiedChinese, .traditionalChinese, .croatian, .czech, .danish, .dutch, .english, .estonian, .finnish, .french, .german, .greek, .hebrew, .hindi, .hungarian, .indonesian, .italian, .japanese, .korean, .latvian, .lithuanian, .norwegian, .polish, .portuguese, .romanian, .russian, .serbian, .slovak, .slovenian, .spanish, .swedish, .thai, .turkish, .ukrainian, .vietnamese], + .portuguese: [.arabic, .bengali, .bulgarian, .simplifiedChinese, .traditionalChinese, .croatian, .czech, .danish, .dutch, .english, .estonian, .finnish, .french, .german, .greek, .hebrew, .hindi, .hungarian, .indonesian, .italian, .japanese, .korean, .latvian, .lithuanian, .norwegian, .polish, .portuguese, .romanian, .russian, .serbian, .slovak, .slovenian, .spanish, .swedish, .thai, .turkish, .ukrainian, .vietnamese], + .romanian: [.arabic, .bengali, .bulgarian, .simplifiedChinese, .traditionalChinese, .croatian, .czech, .danish, .dutch, .english, .estonian, .finnish, .french, .german, .greek, .hebrew, .hindi, .hungarian, .indonesian, .italian, .japanese, .korean, .latvian, .lithuanian, .norwegian, .polish, .portuguese, .romanian, .russian, .serbian, .slovak, .slovenian, .spanish, .swedish, .thai, .turkish, .ukrainian, .vietnamese], + .russian: [.arabic, .bengali, .bulgarian, .simplifiedChinese, .traditionalChinese, .croatian, .czech, .danish, .dutch, .english, .estonian, .finnish, .french, .german, .greek, .hebrew, .hindi, .hungarian, .indonesian, .italian, .japanese, .korean, .latvian, .lithuanian, .norwegian, .polish, .portuguese, .romanian, .russian, .serbian, .slovak, .slovenian, .spanish, .swedish, .thai, .turkish, .ukrainian, .vietnamese], + .serbian: [.arabic, .bengali, .bulgarian, .simplifiedChinese, .traditionalChinese, .croatian, .czech, .danish, .dutch, .english, .estonian, .finnish, .french, .german, .greek, .hebrew, .hindi, .hungarian, .indonesian, .italian, .japanese, .korean, .latvian, .lithuanian, .norwegian, .polish, .portuguese, .romanian, .russian, .serbian, .slovak, .slovenian, .spanish, .swedish, .thai, .turkish, .ukrainian, .vietnamese], + .slovak: [.arabic, .bengali, .bulgarian, .simplifiedChinese, .traditionalChinese, .croatian, .czech, .danish, .dutch, .english, .estonian, .finnish, .french, .german, .greek, .hebrew, .hindi, .hungarian, .indonesian, .italian, .japanese, .korean, .latvian, .lithuanian, .norwegian, .polish, .portuguese, .romanian, .russian, .serbian, .slovak, .slovenian, .spanish, .swedish, .thai, .turkish, .ukrainian, .vietnamese], + .slovenian: [.arabic, .bengali, .bulgarian, .simplifiedChinese, .traditionalChinese, .croatian, .czech, .danish, .dutch, .english, .estonian, .finnish, .french, .german, .greek, .hebrew, .hindi, .hungarian, .indonesian, .italian, .japanese, .korean, .latvian, .lithuanian, .norwegian, .polish, .portuguese, .romanian, .russian, .serbian, .slovak, .slovenian, .spanish, .swedish, .thai, .turkish, .ukrainian, .vietnamese], + .spanish: [.arabic, .bengali, .bulgarian, .simplifiedChinese, .traditionalChinese, .croatian, .czech, .danish, .dutch, .english, .estonian, .finnish, .french, .german, .greek, .hebrew, .hindi, .hungarian, .indonesian, .italian, .japanese, .korean, .latvian, .lithuanian, .norwegian, .polish, .portuguese, .romanian, .russian, .serbian, .slovak, .slovenian, .spanish, .swedish, .thai, .turkish, .ukrainian, .vietnamese], +// .swahili/kiswahili: [.swahili/kiswahili], Swahili language: not supported by Easydict + .swedish: [.arabic, .bengali, .bulgarian, .simplifiedChinese, .traditionalChinese, .croatian, .czech, .danish, .dutch, .english, .estonian, .finnish, .french, .german, .greek, .hebrew, .hindi, .hungarian, .indonesian, .italian, .japanese, .korean, .latvian, .lithuanian, .norwegian, .polish, .portuguese, .romanian, .russian, .serbian, .slovak, .slovenian, .spanish, .swedish, .thai, .turkish, .ukrainian, .vietnamese], + .thai: [.arabic, .bengali, .bulgarian, .simplifiedChinese, .traditionalChinese, .croatian, .czech, .danish, .dutch, .english, .estonian, .finnish, .french, .german, .greek, .hebrew, .hindi, .hungarian, .indonesian, .italian, .japanese, .korean, .latvian, .lithuanian, .norwegian, .polish, .portuguese, .romanian, .russian, .serbian, .slovak, .slovenian, .spanish, .swedish, .thai, .turkish, .ukrainian, .vietnamese], + .turkish: [.arabic, .bengali, .bulgarian, .simplifiedChinese, .traditionalChinese, .croatian, .czech, .danish, .dutch, .english, .estonian, .finnish, .french, .german, .greek, .hebrew, .hindi, .hungarian, .indonesian, .italian, .japanese, .korean, .latvian, .lithuanian, .norwegian, .polish, .portuguese, .romanian, .russian, .serbian, .slovak, .slovenian, .spanish, .swedish, .thai, .turkish, .ukrainian, .vietnamese], + .ukrainian: [.arabic, .bengali, .bulgarian, .simplifiedChinese, .traditionalChinese, .croatian, .czech, .danish, .dutch, .english, .estonian, .finnish, .french, .german, .greek, .hebrew, .hindi, .hungarian, .indonesian, .italian, .japanese, .korean, .latvian, .lithuanian, .norwegian, .polish, .portuguese, .romanian, .russian, .serbian, .slovak, .slovenian, .spanish, .swedish, .thai, .turkish, .ukrainian, .vietnamese], + .vietnamese: [.arabic, .bengali, .bulgarian, .simplifiedChinese, .traditionalChinese, .croatian, .czech, .danish, .dutch, .english, .estonian, .finnish, .french, .german, .greek, .hebrew, .hindi, .hungarian, .indonesian, .italian, .japanese, .korean, .latvian, .lithuanian, .norwegian, .polish, .portuguese, .romanian, .russian, .serbian, .slovak, .slovenian, .spanish, .swedish, .thai, .turkish, .ukrainian, .vietnamese], + ] + + static let supportLanguagesDictionary: [Language: String] = [ + .arabic: "ar", + .bengali: "bn", + .bulgarian: "bg", + .simplifiedChinese: "zh", + .traditionalChinese: "zh", + .croatian: "hr", + .czech: "cs", + .danish: "da", + .dutch: "nl", + .english: "en", + .estonian: "et", + .finnish: "fi", + .french: "fr", + .german: "de", + .greek: "el", + .hebrew: "iw", + .hindi: "hi", + .hungarian: "hu", + .indonesian: "id", + .italian: "it", + .japanese: "ja", + .korean: "ko", + .latvian: "lv", + .lithuanian: "lt", + .norwegian: "no", + .polish: "pl", + .portuguese: "pt", + .romanian: "ro", + .russian: "ru", + .serbian: "sr", + .slovak: "sk", + .slovenian: "sl", + .spanish: "es", +// .swahili/kiswahili: "sw", + .swedish: "sv", + .thai: "th", + .turkish: "tr", + .ukrainian: "uk", + .vietnamese: "vi", + ] + + static func transType(from: Language, to: Language) -> GeminiTranslateType { + // Treat traditional Chinese as simplified Chinese. + if from == .traditionalChinese { + return transType(from: .simplifiedChinese, to: to) + } + + // We can auto convert to Traditional Chinese. + guard let targetLanguages = supportedTypes[from], + targetLanguages.contains(to) || to == .traditionalChinese + else { + return .unsupported + } + + guard let from = supportLanguagesDictionary[from], + let to = supportLanguagesDictionary[to] + else { + return .unsupported + } + + return GeminiTranslateType(rawValue: "\(from)2\(to)") + } +}