Helper.swift 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. //
  2. // Helper.swift
  3. // Learn Genie
  4. //
  5. // Created by Suraj Kumar Mandal on 31/08/21.
  6. //
  7. import Foundation
  8. import UIKit
  9. class Helper {
  10. static func showHudWithNoInteraction(show: Bool,view: UIView) {
  11. if show {
  12. NetworkIndicator.networkIndicator.showProgressView(view)
  13. }
  14. }
  15. static func dismissProgressHud() {
  16. NetworkIndicator.networkIndicator.hideProgressView()
  17. }
  18. static func translateText(inputText: String) -> String {
  19. let translateData = DBManager.sharedInstance.database.objects(TranslationModel.self)
  20. let id = UserDefaultsConstant.getIntValueFromUserDefults(for: "selectedLanguageId") as! Int
  21. print(translateData.count)
  22. var text = ""
  23. for item in translateData {
  24. if id == item.languageId && inputText.lowercased() == item.originalText.lowercased() {
  25. print(item.languageId, item.originalText, item.translatedText, item.id)
  26. print(item.originalText.lowercased())
  27. text = item.translatedText
  28. print(text)
  29. break
  30. } else {
  31. text = inputText
  32. }
  33. }
  34. return text
  35. }
  36. }