Browse Source

added Utils method to get device language

nayooti 5 năm trước cách đây
mục cha
commit
35918f714d
1 tập tin đã thay đổi với 8 bổ sung0 xóa
  1. 8 0
      deltachat-ios/Helper/Utils.swift

+ 8 - 0
deltachat-ios/Helper/Utils.swift

@@ -161,6 +161,14 @@ struct Utils {
             return nil
             return nil
         }
         }
     }
     }
+
+    static func getDeviceLanguage() -> String? {
+        // some device languages have suffixes (like en-aus etc.) so we want to cut suffixes off
+        guard let lang = Locale.preferredLanguages.first?.split(separator: "-").first else {
+            return nil
+        }
+        return String(lang)
+    }
 }
 }
 
 
 class DateUtils {
 class DateUtils {