How to get current language code with Swift?

前端 未结 13 2086
难免孤独
难免孤独 2020-12-07 11:06

I want get the language code of the device (en, es...) in my app written with Swift. How can get this?

I\'m trying this:

var preferredLanguages : NSL         


        
13条回答
  •  忘掉有多难
    2020-12-07 11:44

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

    var preferredLanguage : String = Bundle.main.preferredLocalizations.first!
    

提交回复
热议问题