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?
我的应用程序中有一个语言选择控件,我希望能够在运行时相应地设置语言环境。我怎样才能做到这一点?
1 个解决方案
#1
12
I found the answer
我找到了答案
NSUserDefaults.standardUserDefaults().setObject(["fr"], forKey: "AppleLanguages")
NSUserDefaults.standardUserDefaults().synchronize()
Swift 3:
斯威夫特3:
UserDefaults.standard.set(["fr"], forKey: "AppleLanguages")
UserDefaults.standard.synchronize()
#1
12
I found the answer
我找到了答案
NSUserDefaults.standardUserDefaults().setObject(["fr"], forKey: "AppleLanguages")
NSUserDefaults.standardUserDefaults().synchronize()
Swift 3:
斯威夫特3:
UserDefaults.standard.set(["fr"], forKey: "AppleLanguages")
UserDefaults.standard.synchronize()