Getting current device language in iOS?

前端 未结 30 2349
星月不相逢
星月不相逢 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:20

    Swift

    To get current language of device

    NSLocale.preferredLanguages()[0] as String
    

    To get application language

    NSBundle.mainBundle().preferredLocalizations[0] as NSString
    

    Note:

    It fetches the language that you have given in CFBundleDevelopmentRegion of info.plist

    if CFBundleAllowMixedLocalizations is true in info.plist then first item of CFBundleLocalizations in info.plist is returned

提交回复
热议问题