开发者

Change language of the ios application

开发者 https://www.devze.com 2023-04-09 08:25 出处:网络
I\'ve put my app settings into iPhone Settings panel. I want to switch between languages independently of the iPh开发者_JAVA百科one system language. Is it possible? I\'m using this advice:

I've put my app settings into iPhone Settings panel. I want to switch between languages independently of the iPh开发者_JAVA百科one system language. Is it possible? I'm using this advice: How to force NSLocalizedString to use a specific language

But it translates only string inside app, but my nib files are same. How to reload my nibs?


The key is to override the NSUserDefaults language key before UIApplicationMain() is called in your main() function in main.m. Try something like this in your main() function:

// use whatever language/locale id you want to override
[[NSUserDefaults standardUserDefaults] setObject:[NSArray arrayWithObjects:@"de_DE", nil]
                                          forKey:@"AppleLanguages"];
[[NSUserDefaults standardUserDefaults] synchronize];
int retVal = UIApplicationMain(argc, argv, nil, nil);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号