Check language in iOS app
Swift 5
Locale.current.regionCode // Optional("US")
Locale.current.languageCode // Optional("en")
Locale.current.identifier // en_US
With extension
extension Locale {
var isKorean: Bool {
return languageCode == "ko"
}
}
Locale.current.isKorean => false
Swift 3 You can take the language code like this
let preferredLanguage = NSLocale.preferredLanguages[0]
And then you need to compare it with code string
if preferredLanguage == "en" {
print("this is English")
} else if preferredLanguage == "uk" {
print("this is Ukrainian")
}
You can find codes here
An example to check if French ...
/// Is Device use french language
/// Consider, "fr-CA", "fr-FR", "fr-CH" et cetera
///
/// - Returns: Bool
static func isFrench() -> Bool {
return NSLocale.preferredLanguages[0].range(of:"fr") != nil
}