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?
Asked
Active
Viewed 8,578 times
1 Answers
12
I found the answer
NSUserDefaults.standardUserDefaults().setObject(["fr"], forKey: "AppleLanguages")
NSUserDefaults.standardUserDefaults().synchronize()
Swift 3:
UserDefaults.standard.set(["fr"], forKey: "AppleLanguages")
UserDefaults.standard.synchronize()

Ahmad Farrag
- 234
- 2
- 8

daaniaal
- 501
- 7
- 13
-
can you specify where did you put this? – cduguet Dec 02 '15 at 03:34
-
@daaniaal . Please could u help me how can i change the language without restarting the app – Uma Madhavi Sep 15 '17 at 09:07
-
1It seems to work only after you restart the app (iOS 11) – Daniel Feb 14 '18 at 09:41
-
It doesn't work before restart in ios 11 – mert Apr 05 '18 at 15:05
-
This is beyond a wrong answer... I hope no one actually copied this... – TheCodingArt Oct 10 '19 at 12:39