Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I change the locale for my app programmatically via Swift? [closed]

Tags:

swift

nslocale

I have a language selection control in my application, and I want to be able to set the locale accordingly during runtime. How can I achieve this?

like image 274
daaniaal Avatar asked Dec 28 '14 09:12

daaniaal


1 Answers

I found the answer

NSUserDefaults.standardUserDefaults().setObject(["fr"], forKey: "AppleLanguages")
NSUserDefaults.standardUserDefaults().synchronize()

Swift 3:

UserDefaults.standard.set(["fr"], forKey: "AppleLanguages")
UserDefaults.standard.synchronize()
like image 162
daaniaal Avatar answered Sep 20 '22 15:09

daaniaal