Explorar o código

added Utils method to get device language

nayooti %!s(int64=5) %!d(string=hai) anos
pai
achega
35918f714d
Modificáronse 1 ficheiros con 8 adicións e 0 borrados
  1. 8 0
      deltachat-ios/Helper/Utils.swift

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

@@ -161,6 +161,14 @@ struct Utils {
             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 {