Getting current device language in iOS?

前端 未结 30 2758
星月不相逢
星月不相逢 2020-11-22 09:10

I\'d like to show the current language that the device UI is using. What code would I use?

I want this as an NSString in fully spelled out format. (Not

30条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-22 09:24

    Swift 3

    let locale = Locale.current
    let code = (locale as NSLocale).object(forKey: NSLocale.Key.countryCode) as! String?
    print(code!)
    

提交回复
热议问题