KMTTSWindowController.swift 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545
  1. //
  2. // KMTTSWindowController.swift
  3. // PDF Reader Pro
  4. //
  5. // Created by liujiajie on 2023/12/12.
  6. //
  7. import Cocoa
  8. typealias TTSCloseWindowCallback = (_ isCloseWindow: Bool) -> Void
  9. let minSpeed: Float = 0.6
  10. let maxSpeed: Float = 5.0
  11. let standardSpeed: Float = 175.0
  12. class KMTTSWindowController: NSWindowController, KMTTSManagerDelegate, NSWindowDelegate, NSTextFieldDelegate{
  13. var pdfView: CPDFView!
  14. var closeWindowCallback: TTSCloseWindowCallback?
  15. @IBOutlet var sontinuouButton: NSButton!
  16. @IBOutlet var speedLabel: NSTextField!
  17. @IBOutlet var languageLabel: NSTextField!
  18. @IBOutlet var languageComboBox: NSPopUpButton!
  19. @IBOutlet var speedTextField: NSTextField!
  20. @IBOutlet var speedSlider: NSSlider!
  21. @IBOutlet var speedStepper: NSStepper!
  22. @IBOutlet var nextButton: KMToolbarItem!
  23. @IBOutlet var forwardButton: KMToolbarItem!
  24. @IBOutlet var playButton: KMToolbarItem!
  25. @IBOutlet var speedBox: NSBox!
  26. @IBOutlet var sppendCountLabel: NSTextField!
  27. var pdfSelection: CPDFSelection?
  28. var currentPageIndex: Int = 0
  29. var isChangePage = false
  30. var voiceArrays = NSMutableArray()
  31. static let share = KMTTSWindowController()
  32. convenience init() {
  33. self.init(windowNibName: "KMTTSWindowController")
  34. }
  35. deinit {
  36. DistributedNotificationCenter.default().removeObserver(self)
  37. NotificationCenter.default.removeObserver(self)
  38. }
  39. override func windowDidLoad() {
  40. super.windowDidLoad()
  41. self.speedStepper.minValue = Double(minSpeed)
  42. self.speedStepper.maxValue = Double(maxSpeed);
  43. self.speedSlider.minValue = Double(minSpeed);
  44. self.speedSlider.maxValue = Double(maxSpeed);
  45. self.nextButton.toolTip = KMLocalizedString("Next Page", nil)
  46. // self.nextButton.isShowCustomToolTip = true
  47. self.forwardButton.toolTip = KMLocalizedString("Previous Page", nil)
  48. // self.forwardButton.isShowCustomToolTip = true
  49. self.speedSlider.isEnabled = true
  50. self.speedStepper.isEnabled = true
  51. self.playButton.toolTip = KMLocalizedString("Play", nil)
  52. // self.playButton.isShowCustomToolTip = true
  53. self.sppendCountLabel.stringValue = KMLocalizedString("SpeedX", nil)
  54. let str = String(format: "%.1f", KMTTSManager.defalutManager.rate/Float(standardSpeed))
  55. self.speedStepper.stringValue = str
  56. self.speedTextField.stringValue = str
  57. self.speedSlider.stringValue = str//[NSString stringWithFormat:@"%.1f",([KMTTSManager defaultManager].rate/standardSpeed)];
  58. self.sontinuouButton.title = KMLocalizedString("Continuous Reading", nil);
  59. self.speedLabel.stringValue = KMLocalizedString("Speed", nil) + ":"//[NSString stringWithFormat:@"%@:",KMLocalizedString("Speed", nil)];
  60. self.languageLabel.stringValue = KMLocalizedString("Language", nil) + ":" //[NSString stringWithFormat:@"%@:",KMLocalizedString(@"Language", nil)];
  61. let array = KMTTSManager.defalutManager.availableVoices()
  62. let currentVoicName = KMTTSManager.defalutManager.voice()
  63. var currentIndex = 0
  64. let menu = NSMenu()
  65. for voiceType: NSSpeechSynthesizer.VoiceName in array {
  66. let voiceDic = NSMutableDictionary()
  67. // let dic = KMTTSManager.defalutManager.attributesForVoice(voiceType)
  68. let voiceLocaleIdentifier = ( NSSpeechSynthesizer.attributes( forVoice: voiceType )[ NSSpeechSynthesizer.VoiceAttributeKey.localeIdentifier ] as! String )
  69. let name = self.switchLanguage(withCode: voiceLocaleIdentifier)
  70. voiceDic["voiceType"] = voiceType
  71. voiceDic["voiceName"] = name
  72. voiceArrays.add(voiceDic)
  73. }
  74. voiceArrays = self.sortArray(voiceArrays)
  75. for i in 0..<voiceArrays.count {
  76. let voiceDic = voiceArrays[i] as! NSDictionary
  77. let voiceType = voiceDic.object(forKey: "voiceType") as! NSSpeechSynthesizer.VoiceName
  78. if currentVoicName == voiceType {
  79. currentIndex = i
  80. }
  81. let dic = KMTTSManager.defalutManager.attributesForVoice(voiceType) as NSDictionary
  82. let code = ( NSSpeechSynthesizer.attributes( forVoice: voiceType )[ NSSpeechSynthesizer.VoiceAttributeKey.localeIdentifier ] as! String )
  83. var languageStaring: String? = nil
  84. let voiceName = ( NSSpeechSynthesizer.attributes( forVoice: voiceType )[ NSSpeechSynthesizer.VoiceAttributeKey.name ] as! String )
  85. let name = self.switchLanguage(withCode: code)
  86. if voiceName.count > 0 {
  87. languageStaring = "\(name)(\(voiceName))"
  88. }
  89. let font = NSFont.systemFont(ofSize: 12.0)
  90. let namefont = NSFont.systemFont(ofSize: 10.0)
  91. let textRowSpace = NSMutableAttributedString(string: languageStaring ?? "")
  92. textRowSpace.addAttribute(.font, value: font, range: NSRange(location: 0, length: name.count))
  93. textRowSpace.addAttribute(.font, value: namefont, range: NSRange(location: name.count, length: languageStaring!.count - name.count))
  94. let item = NSMenuItem()
  95. item.attributedTitle = textRowSpace
  96. menu.addItem(item)
  97. }
  98. self.languageComboBox.menu = menu
  99. self.languageComboBox.selectItem(at: currentIndex)
  100. KMTTSManager.defalutManager.delegate = self
  101. self.updateViewColor()
  102. self.window?.standardWindowButton(.zoomButton)?.isHidden = true
  103. if KMTTSManager.defalutManager.isContinue {
  104. self.sontinuouButton.state = .on
  105. } else {
  106. self.sontinuouButton.state = .off
  107. }
  108. DistributedNotificationCenter.default().addObserver(self, selector: #selector(themeChanged(notification:)), name: NSNotification.Name("AppleInterfaceThemeChangedNotification"), object: nil)
  109. NotificationCenter.default.addObserver(self, selector: #selector(handlePageChangedNotification), name: NSNotification.Name.CPDFViewPageChanged, object: self.pdfView)
  110. }
  111. func updateViewColor() {
  112. var viewBackcolor = NSColor(red: 255.0/255.0, green: 255.0/255.0, blue: 255.0/255.0, alpha: 1.0)
  113. var textColor = NSColor(red: 51.0/255.0, green: 51.0/255.0, blue: 51.0/255.0, alpha: 1.0)
  114. var contentColor = NSColor(red: 102.0/255.0, green: 102.0/255.0, blue: 102.0/255.0, alpha: 1.0)
  115. var fillColor = NSColor.white
  116. if #available(macOS 10.14, *) {
  117. let appearanceName = NSApp.effectiveAppearance.bestMatch(from: [.aqua, .darkAqua])
  118. if appearanceName == .darkAqua {
  119. viewBackcolor = NSColor(red: 69.0/255.0, green: 69.0/255.0, blue: 71.0/255.0, alpha: 1.0)
  120. textColor = NSColor(red: 255.0/255.0, green: 255.0/255.0, blue: 255.0/255.0, alpha: 1.0)
  121. contentColor = NSColor(red: 255.0/255.0, green: 255.0/255.0, blue: 255.0/255.0, alpha: 0.6)
  122. fillColor = NSColor(red: 101.0/255.0, green: 101.0/255.0, blue: 101.0/255.0, alpha: 1.0)
  123. }
  124. }
  125. self.window?.backgroundColor = viewBackcolor
  126. self.window?.isMovableByWindowBackground = true
  127. self.languageLabel.textColor = contentColor
  128. self.speedLabel.textColor = contentColor
  129. self.speedTextField.textColor = textColor
  130. self.speedBox.fillColor = fillColor
  131. self.sontinuouButton.setTitleColor(contentColor)
  132. }
  133. @objc func themeChanged(notification: NSNotification) {
  134. DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
  135. self.updateViewColor()
  136. }
  137. }
  138. @objc func handlePageChangedNotification(notification: NSNotification) {
  139. guard let PDFView = notification.object as? CPDFView else { return }
  140. if PDFView == self.pdfView {
  141. if self.pdfView.canGoToNextPage() {
  142. self.nextButton.isEnabled = true
  143. } else{
  144. self.nextButton.isEnabled = false
  145. }
  146. if self.pdfView.canGoToPreviousPage() {
  147. self.forwardButton.isEnabled = true
  148. } else {
  149. self.forwardButton.isEnabled = false
  150. }
  151. }
  152. }
  153. func sortArray(_ array: NSArray) -> NSMutableArray {
  154. let sortDesc = [NSSortDescriptor(key: "voiceName", ascending: true)]
  155. let sortedArr = array.sortedArray(using: sortDesc) as NSArray
  156. let tArray = NSMutableArray(array: sortedArr)
  157. return tArray
  158. }
  159. func windowShouldClose(_ sender: NSWindow) -> Bool {
  160. self.stopSpeaking()
  161. if let callBlack = closeWindowCallback {
  162. callBlack(true)
  163. }
  164. return true
  165. }
  166. override func showWindow(_ sender: Any?) {
  167. super.showWindow(sender)
  168. self.isChangePage = false
  169. if self.pdfView.canGoToNextPage() {
  170. self.nextButton.isEnabled = true
  171. } else{
  172. self.nextButton.isEnabled = false
  173. }
  174. if self.pdfView.canGoToPreviousPage() {
  175. self.forwardButton.isEnabled = true
  176. } else {
  177. self.forwardButton.isEnabled = false
  178. }
  179. }
  180. func stopSpeaking() {
  181. if KMTTSManager.defalutManager.isSpeaking() || KMTTSManager.defalutManager.isPaused {
  182. self.isChangePage = true
  183. KMTTSManager.defalutManager.stopSpeaking()
  184. self.speedSlider.isEnabled = true
  185. self.speedStepper.isEnabled = true
  186. self.playButton.image = NSImage(named: "KMImageNameTTSStop")
  187. self.playButton.toolTip = NSLocalizedString("Play", comment: "")
  188. self.pdfView.setHighlightedSelections([])
  189. }
  190. self.pdfSelection = nil
  191. self.pdfView = nil
  192. }
  193. func quikeStartSpeakingPDFPage(_ page: CPDFPage) {
  194. if KMTTSManager.defalutManager.isSpeaking() || KMTTSManager.defalutManager.isPaused {
  195. KMTTSManager.defalutManager.stopSpeaking()
  196. self.isChangePage = true
  197. }
  198. self.currentPageIndex = Int(self.pdfView.document?.index(for: page) ?? 0)
  199. self.startSpeakingPDFPage(page)
  200. }
  201. func startSpeakingPDFPage(_ page: CPDFPage) {
  202. let dex = self.languageComboBox.indexOfSelectedItem
  203. if dex >= 0 && dex < self.voiceArrays.count {
  204. let dic: NSMutableDictionary = self.voiceArrays[dex] as! NSMutableDictionary
  205. if let voiceName = dic["voiceType"] {
  206. KMTTSManager.defalutManager.setVoice(voice: voiceName as! NSSpeechSynthesizer.VoiceName)
  207. }
  208. }
  209. KMTTSManager.defalutManager.rate = self.speedSlider.floatValue * Float(standardSpeed)
  210. let isSuccess = KMTTSManager.defalutManager.startSpeakingPDFPage(page)
  211. if isSuccess {
  212. self.playButton.image = NSImage(named: "KMImageNameTTSPause")
  213. self.playButton.toolTip = NSLocalizedString("Pause", comment: "")
  214. self.speedSlider.isEnabled = false
  215. self.speedStepper.isEnabled = false
  216. } else {
  217. self.playButton.image = NSImage(named: "KMImageNameTTSStop")
  218. self.playButton.toolTip = NSLocalizedString("Play", comment: "")
  219. self.speedSlider.isEnabled = true
  220. self.speedStepper.isEnabled = true
  221. }
  222. }
  223. func startSpeakingPDFSelection(_ selection: CPDFSelection) {
  224. if KMTTSManager.defalutManager.isSpeaking() || KMTTSManager.defalutManager.isPaused {
  225. KMTTSManager.defalutManager.stopSpeaking()
  226. self.isChangePage = true
  227. }
  228. self.pdfSelection = selection
  229. self.pdfView?.setCurrentSelection(nil, animate: false)
  230. let dex = self.languageComboBox.indexOfSelectedItem
  231. if dex >= 0 && dex < self.voiceArrays.count {
  232. let dic: NSMutableDictionary = self.voiceArrays[dex] as! NSMutableDictionary
  233. if let voiceName = dic["voiceType"] as? NSSpeechSynthesizer.VoiceName {
  234. KMTTSManager.defalutManager.setVoice(voice: voiceName)
  235. }
  236. }
  237. KMTTSManager.defalutManager.rate = self.speedSlider.floatValue * Float(standardSpeed)
  238. let isSuccess = KMTTSManager.defalutManager.startSpeakingPDFSelection(selection)
  239. if isSuccess {
  240. self.speedSlider.isEnabled = false
  241. self.speedStepper.isEnabled = false
  242. self.playButton.image = NSImage(named: "KMImageNameTTSPause")
  243. self.playButton.toolTip = NSLocalizedString("Pause", comment: "")
  244. } else {
  245. self.speedSlider.isEnabled = true
  246. self.speedStepper.isEnabled = true
  247. self.playButton.image = NSImage(named: "KMImageNameTTSStop")
  248. self.playButton.toolTip = NSLocalizedString("Play", comment: "")
  249. }
  250. }
  251. @IBAction func buttonItemClick_Next(_ sender: NSButton) {
  252. if (KMTTSManager.defalutManager.isSpeaking()) {
  253. var currentPageNum = self.currentPageIndex;
  254. var page: CPDFPage?
  255. if (currentPageNum + 1 < self.pdfView.document.pageCount) {
  256. page = self.pdfView.document.page(at: UInt(currentPageNum+1))
  257. self.currentPageIndex = currentPageNum + 1;
  258. } else {
  259. page = self.pdfView.document.page(at: self.pdfView.document.pageCount - 1)
  260. self.currentPageIndex = Int(self.pdfView.document.pageCount - 1)
  261. }
  262. self.pdfView.go(to: page)
  263. self.isChangePage = true
  264. self.startSpeakingPDFPage(page!)
  265. }
  266. }
  267. @IBAction func buttonItemClick_Forward(_ sender: NSButton) {
  268. if (KMTTSManager.defalutManager.isSpeaking()) {
  269. var currentPageNum = self.currentPageIndex;
  270. var page: CPDFPage?
  271. if (currentPageNum - 1 < 0) {
  272. page = self.pdfView.document.page(at: 0)
  273. self.currentPageIndex = 0;
  274. } else {
  275. page = self.pdfView.document.page(at: UInt(currentPageNum - 1))
  276. self.currentPageIndex = currentPageNum - 1
  277. }
  278. self.pdfView.go(to: page)
  279. self.isChangePage = true
  280. self.startSpeakingPDFPage(page!)
  281. }
  282. }
  283. @IBAction func buttonItemClick_Play(_ sender: KMToolbarItem) {
  284. if (KMTTSManager.defalutManager.isPaused) {
  285. self.playButton.image = NSImage(named: "KMImageNameTTSPause")
  286. self.playButton.toolTip = KMLocalizedString("Pause", nil)
  287. self.speedSlider.isEnabled = false
  288. self.speedStepper.isEnabled = false
  289. KMTTSManager.defalutManager.continueSpeaking()
  290. } else if (KMTTSManager.defalutManager.isSpeaking()) {
  291. self.isChangePage = true
  292. self.playButton.image = NSImage(named: "KMImageNameTTSStop")
  293. self.playButton.toolTip = KMLocalizedString("Play", nil)
  294. self.speedSlider.isEnabled = true
  295. self.speedStepper.isEnabled = true
  296. self.pdfView.setHighlightedSelection(nil, animated: false)
  297. KMTTSManager.defalutManager.pauseSpeaking()
  298. } else {
  299. if ((self.pdfSelection) != nil) {
  300. self.startSpeakingPDFSelection(self.pdfSelection!)
  301. } else {
  302. let page = self.pdfView.currentPage()
  303. self.currentPageIndex = self.pdfView.currentPageIndex
  304. self.startSpeakingPDFPage(page!)
  305. }
  306. }
  307. }
  308. @IBAction func buttonItemClick_Continue(_ sender: NSButton) {
  309. KMTTSManager.defalutManager.isContinue = !(KMTTSManager.defalutManager.isContinue)
  310. }
  311. @IBAction func stepperItemClick_Speed(_ sender: NSButton) {
  312. var rate = self.speedStepper.floatValue
  313. let str = String(format: "%.1f", rate)
  314. self.speedStepper.stringValue = str
  315. self.speedTextField.stringValue = str
  316. self.speedSlider.stringValue = str
  317. rate = Float(standardSpeed) * rate
  318. KMTTSManager.defalutManager.rate = rate
  319. }
  320. @IBAction func sliderItemClick_Speed(_ sender: NSButton) {
  321. var rate: CGFloat = CGFloat(self.speedSlider.floatValue)
  322. let str = String(format: "%.1f", rate)
  323. self.speedStepper.stringValue = str
  324. self.speedTextField.stringValue = str
  325. self.speedSlider.stringValue = str
  326. rate = CGFloat(standardSpeed) * rate
  327. KMTTSManager.defalutManager.rate = Float(rate)
  328. }
  329. @IBAction func buttonItemClick_Language(_ sender: NSButton) {
  330. if KMTTSManager.defalutManager.isSpeaking() {
  331. self.isChangePage = true
  332. if let pdfSelection = self.pdfSelection {
  333. self.startSpeakingPDFSelection(pdfSelection)
  334. } else {
  335. let currentPageInd = self.currentPageIndex
  336. if currentPageInd < (self.pdfView.document.pageCount - 1) {
  337. let page = self.pdfView.document.page(at: UInt(currentPageInd))
  338. self.startSpeakingPDFPage(page!)
  339. }
  340. }
  341. }
  342. }
  343. override func mouseDown(with event: NSEvent) {
  344. super.mouseDown(with: event)
  345. self.window?.makeFirstResponder(self)
  346. }
  347. //MARK: KMTTSManagerDelegate
  348. func ttsMananger(_ tts: KMTTSManager, willSpeak selection: CPDFSelection) {
  349. // if (selection != nil) {
  350. self.pdfView?.setHighlightedSelection(selection, animated: false)
  351. // }
  352. }
  353. func ttsManangerDidFinishSpeech(_ tts: KMTTSManager) -> Bool {
  354. var isFinish = true
  355. if self.pdfSelection != nil {
  356. self.pdfSelection = nil
  357. self.pdfView.setHighlightedSelections(nil)
  358. self.playButton.image = NSImage(named: "KMImageNameTTSStop")
  359. self.speedSlider.isEnabled = true
  360. self.speedStepper.isEnabled = true
  361. self.playButton.toolTip = KMLocalizedString("Play", nil)
  362. } else {
  363. if KMTTSManager.defalutManager.isContinue {
  364. if !isChangePage {
  365. if let pdfSelection = self.pdfSelection {
  366. self.pdfView.setHighlightedSelections(nil)
  367. self.playButton.image = NSImage(named: "KMImageNameTTSStop")
  368. self.speedSlider.isEnabled = true
  369. self.speedStepper.isEnabled = true
  370. self.playButton.toolTip = KMLocalizedString("Play", nil)
  371. } else {
  372. let currentPageIndex = self.currentPageIndex
  373. if currentPageIndex + 1 < self.pdfView.document.pageCount {
  374. let page = self.pdfView.document.page(at: UInt(currentPageIndex+1))
  375. self.currentPageIndex = currentPageIndex+1
  376. self.pdfView.go(to: page)
  377. self.startSpeakingPDFPage(page!)
  378. isFinish = false
  379. } else {
  380. self.pdfView.setHighlightedSelections(nil)
  381. self.playButton.image = NSImage(named: "KMImageNameTTSStop")
  382. self.speedSlider.isEnabled = true
  383. self.speedStepper.isEnabled = true
  384. self.playButton.toolTip = KMLocalizedString("Play", nil)
  385. }
  386. }
  387. }
  388. } else {
  389. if !isChangePage {
  390. self.speedSlider.isEnabled = true
  391. self.speedStepper.isEnabled = true
  392. self.pdfView.setHighlightedSelections(nil)
  393. self.playButton.image = NSImage(named: "KMImageNameTTSStop")
  394. self.playButton.toolTip = KMLocalizedString("Play", nil)
  395. }
  396. }
  397. if isChangePage {
  398. isChangePage = false
  399. }
  400. }
  401. return isFinish
  402. }
  403. func ttsManangerdidErrorSpeech(_ tts: KMTTSManager, message: String) {
  404. }
  405. //MARK: NSTextFieldDelegate
  406. func controlTextDidEndEditing(_ obj: Notification) {
  407. if let textField = obj.object as? NSTextField {
  408. if textField == self.speedTextField {
  409. var rate: Float = Float(textField.stringValue) ?? 0
  410. if maxSpeed - rate < 0 {
  411. rate = maxSpeed
  412. } else if rate - minSpeed < 0 {
  413. rate = minSpeed
  414. }
  415. self.speedStepper.stringValue = String(format: "%.1f", rate)
  416. self.speedTextField.stringValue = String(format: "%.1f", rate)
  417. self.speedSlider.stringValue = String(format: "%.1f", rate)
  418. rate = standardSpeed * rate
  419. KMTTSManager.defalutManager.rate = rate
  420. }
  421. }
  422. }
  423. func switchLanguage(withCode code: String) -> String {
  424. var language = code
  425. if code == "ar_SA" {
  426. language = "Arabic (Saudi Arabia)"
  427. } else if code == "cs_CZ" {
  428. language = "Czech (Czech republic)"
  429. } else if code == "da_DK" {
  430. language = "Danish (Denmark)"
  431. } else if code == "de_DE" {
  432. language = "German (Germany)"
  433. } else if code == "el_GR" {
  434. language = "Greek (Greece)"
  435. } else if code == "en_AU" {
  436. language = "English (Australia)"
  437. } else if code == "en_GB" {
  438. language = "English (UK)"
  439. } else if code == "en_IE" {
  440. language = "English (Ireland)"
  441. } else if code == "en_US" {
  442. language = "English"
  443. } else if code == "en_ZA" {
  444. language = "English (South Africa)"
  445. } else if code == "es_ES" {
  446. language = "Spanish (Spain)"
  447. } else if code == "es_MX" {
  448. language = "Spanish (Mexico)"
  449. } else if code == "fi_FI" {
  450. language = "Finnish (Finland)"
  451. } else if code == "fr_CA" {
  452. language = "French (Canada)"
  453. } else if code == "fr_FR" {
  454. language = "French (France)"
  455. } else if code == "he_IL" {
  456. language = "Hebrew"
  457. } else if code == "hi_IN" {
  458. language = "Hindi (India)"
  459. } else if code == "hu_HU" {
  460. language = "Hungarian (Hungary)"
  461. } else if code == "id_ID" {
  462. language = "Indonesian (Indonesia)"
  463. } else if code == "it_IT" {
  464. language = "Italian (Italy)"
  465. } else if code == "ja_JP" {
  466. language = "日本語"
  467. } else if code == "ko_KR" {
  468. language = "Korean (South Korea)"
  469. } else if code == "nl_BE" {
  470. language = "Dutch (Belgium)"
  471. } else if code == "nl_NL" {
  472. language = "Dutch (Holland)"
  473. } else if code == "nb_NO" {
  474. language = "Norwegian (Norway)"
  475. } else if code == "pl_PL" {
  476. language = "Polish (Poland)"
  477. } else if code == "pt_BR" {
  478. language = "Portuguese (Brazil)"
  479. } else if code == "pt_PT" {
  480. language = "Portuguese (Portugal)"
  481. } else if code == "ro_RO" {
  482. language = "Romanian (Romania)"
  483. } else if code == "ru_RU" {
  484. language = "Russian (Russia)"
  485. } else if code == "sk_SK" {
  486. language = "Slovakia (Slovakia)"
  487. } else if code == "sv_SE" {
  488. language = "Swe (Sweden)"
  489. } else if code == "th_TH" {
  490. language = "Thai (Thailand)"
  491. } else if code == "tr_TR" {
  492. language = "Turkish (Turkey)"
  493. } else if code == "zh_CN" {
  494. language = "简体中文"
  495. } else if code == "zh_HK" {
  496. language = "繁體中文 (香港)"
  497. } else if code == "zh_TW" {
  498. language = "繁體中文 (台灣)"
  499. } else if code == "en_IN" {
  500. language = "English"
  501. }
  502. return language
  503. }
  504. }