开发者

Can I do an iPhone application that uses a language different than the user's setting?

I'm developing an iPhone application and want to set a location for it different from the user location. I want to have all the files for the internationalization as Apple tell me to do BUT I want to be able to choose the langu开发者_如何学Cage.

Ex: The user is using German but I want my application to be in English!

I want the user to set the language only for the application, no matter the language chosen in the phone, how do I do it?


Not using the framework classes for internationalization. You would have to build your own plumbing for changing labels, buttons, etc throughout your application.


The language is loaded from NSUserDefaults. According to this, you can override it with something like [[NSUserDefaults standardUserDefaults] setObject:[NSArray arrayWithObject:@"en"] forKey:@"AppleLanguage"] and relaunching the app.

Now, the trouble is you need to relaunch the app! One terrible way might be something like this (untested):

UIApplication * app = [UIApplication sharedApplication];
[app openURL:...];
[[NSNotificationCenter defaultCenter] postNotificationName:UIApplicationWillTerminateNotification object:nil userInfo:nil];
[app.delegate applicationWillTerminate:app];
exit(0);

where ... is an HTTP URL that redirects to a custom URL scheme that your app handles (ewwww).

I do not know of an easy way to reload the UI/languages without relaunching the app.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜