LanguagesUtil.swift 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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"{
  15. return Ctext ?? ""
  16. }else{
  17. return Etext ?? ""
  18. }
  19. }
  20. class func isEnLanguage() -> Bool{
  21. let languanges : [String] = UserDefaults.standard.object(forKey: "AppleLanguages") as! [String]
  22. let preferredLanguage = languanges.first
  23. if preferredLanguage == "zh_Hans_CN" || preferredLanguage == "zh-Hant-CN" || preferredLanguage == "zh-Hant-HK" || preferredLanguage == "zh-Hant-MO" || preferredLanguage == "zh-Hant-TW"{
  24. return false
  25. }else{
  26. return true
  27. }
  28. }
  29. }