Swift : How to change language inside app?
found my answer :
NSUserDefaults.standardUserDefaults().setObject(["language identifier"], forKey: "AppleLanguages")
NSUserDefaults.standardUserDefaults().synchronize()
unfortunately user must restart the app! if anyone could find a solution to not restart the application please inform me.
I think KababChi's answer was right. However, in the newer versions of Swift NSUserDefaults
has been substituted by UserDefaults
. So the code would look like this:
UserDefaults.standard.set(languages[indexPath.row], forKey: "AppleLanguages")
UserDefaults.standard.synchronize()
App still needs to be restarted to apply these changes.