diff --git a/Easydict.xcodeproj/project.pbxproj b/Easydict.xcodeproj/project.pbxproj index 82b176ac3..49c60577c 100644 --- a/Easydict.xcodeproj/project.pbxproj +++ b/Easydict.xcodeproj/project.pbxproj @@ -259,7 +259,6 @@ 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 */; }; - 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 */; }; @@ -750,7 +749,6 @@ 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 = ""; }; - 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 = ""; }; @@ -2152,7 +2150,6 @@ isa = PBXGroup; children = ( C415C0AC2B450D4800A9D231 /* GeminiService.swift */, - C415C0B12B45258600A9D231 /* GeminiTranslateType.swift */, ); path = Gemini; sourceTree = ""; @@ -2823,7 +2820,6 @@ 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 */, EAED41EC2B54AA920005FE0A /* ServiceConfigurationSection.swift in Sources */, 276742092B3DC230002A2C75 /* AboutTab.swift in Sources */, diff --git a/Easydict/Feature/Service/Gemini/GeminiService.swift b/Easydict/Feature/Service/Gemini/GeminiService.swift index 6041e4c89..3d9eb13e0 100644 --- a/Easydict/Feature/Service/Gemini/GeminiService.swift +++ b/Easydict/Feature/Service/Gemini/GeminiService.swift @@ -23,12 +23,19 @@ public final class GeminiService: QueryService { NSLocalizedString("gemini_translate", comment: "The name of Gemini Translate") } + // https://ai.google.dev/available_regions + private static let unsupportedLanguages: [Language] = [.persian, .filipino, .khmer, .lao, .malay, .mongolian, .burmese, .telugu, .tamil, .urdu] + override public func supportLanguagesDictionary() -> MMOrderedDictionary { // TODO: Replace MMOrderedDictionary. let orderedDict = MMOrderedDictionary() - GeminiTranslateType.supportLanguagesDictionary.forEach { key, value in - orderedDict.setObject(value as NSString, forKey: key.rawValue as NSString) + for language in EZLanguageManager.shared().allLanguages { + var value = language.rawValue + if !GeminiService.unsupportedLanguages.contains(language) { + orderedDict.setObject(value as NSString, forKey: language.rawValue as NSString) + } } + return orderedDict } diff --git a/Easydict/Feature/Service/Gemini/GeminiTranslateType.swift b/Easydict/Feature/Service/Gemini/GeminiTranslateType.swift deleted file mode 100644 index aaa969ff1..000000000 --- a/Easydict/Feature/Service/Gemini/GeminiTranslateType.swift +++ /dev/null @@ -1,122 +0,0 @@ -// -// 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)") - } -}