Reputation: 1
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 language.
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?
Upvotes: 0
Views: 218
Reputation: 33592
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.
Upvotes: 1
Reputation: 7758
Not using the framework classes for internationalization. You would have to build your own plumbing for changing labels, buttons, etc throughout your application.
Upvotes: 1