Check language in iOS app

Task is : I have got two UIImageViews, and I want present ImageView1 if system language is Ukrainian, and if it is not Ukrainian(English/Polish etc) I want present ImageView2.

I tried :

  • How can I concatenate NSAttributedStrings?
  • iOS4: how do I use video file as an OpenGL texture?
  • How do I solve a 'NSUnknownKeyException' … setValue:forUndefinedKey:]: …not key value coding compliant
  • UIPrintInteractionController prints mot in A4 format
  • AVVideoCompositionCoreAnimationTool and CALayer in portrait mode?
  • iOS6 Preferred Interface Orientation Not Working
  • println(NSUserDefaults.standardUserDefaults().objectForKey("AppleLanguages"))

    but this code gives only list of available languages. I also tried

    var language: AnyObject? = NSLocale.preferredLanguages().first

    but how can I compare this variable with English or Ukrainian language?

    2 Solutions Collect From Internet About “Check language in iOS app”

    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

    you may use the below code
    it works fine with swift 3

        if Bundle.main.preferredLocalizations.first == "en" {
            print("this is english")
           print("this not english")