LanguagesUtil.swift 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. //
  2. // LanguagesUtil.swift
  3. // ADHTuanCan
  4. //
  5. // Created by 敖德亨 on 2023/10/25.
  6. //
  7. import UIKit
  8. @objc(LanguagesUtil)
  9. @objcMembers
  10. class LanguagesUtil: NSObject {
  11. class func createTextBy(Ctext:String?,Etext:String?) -> String{
  12. let languanges : [String] = UserDefaults.standard.object(forKey: "AppleLanguages") as! [String]
  13. let preferredLanguage = languanges.first
  14. // if preferredLanguage == "zh-Hans-CN" || preferredLanguage == "zh-Hant-CN" || preferredLanguage == "zh-Hant-HK" || preferredLanguage == "zh-Hant-MO" || preferredLanguage == "zh-Hant-TW" || preferredLanguage == "zh-Hans-US"{
  15. // return Ctext ?? ""
  16. // }else{
  17. // return Etext ?? ""
  18. // }
  19. if preferredLanguage!.contains("zh"){
  20. return Ctext ?? ""
  21. }else{
  22. return Etext ?? ""
  23. }
  24. }
  25. class func isEnLanguage() -> Bool{
  26. let languanges : [String] = UserDefaults.standard.object(forKey: "AppleLanguages") as! [String]
  27. let preferredLanguage = languanges.first
  28. if preferredLanguage!.contains("zh"){
  29. return false
  30. }else{
  31. return true
  32. }
  33. // if preferredLanguage == "zh-Hans-CN" || preferredLanguage == "zh-Hant-CN" || preferredLanguage == "zh-Hant-HK" || preferredLanguage == "zh-Hant-MO" || preferredLanguage == "zh-Hant-TW" || preferredLanguage == "zh-Hans-US"{
  34. // return false
  35. // }else{
  36. // return true
  37. // }
  38. }
  39. }