Get Current Device Language For iOS
Sep 3, 2019
If you want to know what current device language is for iOS, you can use NSLocale.preferredLanguages.first. This will give you the most preferred language user setup in system. Which is also the system language. This will gives you a string identifier. Here is a list of string identifier for iOS.
If you want to know if user system is French, using string comparison has a problem. Because there can be multiple result being French. Fro example: fr_CA, fr_FR. etc. So I use preferredLanguage?.starts(with: “fr”) to see if it is French.
Complete code:
1 | DeviceLocaleType { |
