Setting default language for iPhone app on first run
Posted
by RaYell
on Stack Overflow
See other posts from Stack Overflow
or by RaYell
Published on 2010-05-31T12:57:59Z
Indexed on
2010/05/31
13:03 UTC
Read the original article
Hit count: 333
I'm developing an application that should support two languages: English and French. However because English translation is not done yet we want to deploy it in French only and later on add English translation later on.
The problem is that I don't want to strip English language out of my code since some parts are already done, there are different NIBs for that language etc. Instead I'd just want english language to be temporary disabled in my app.
What I did is I put this code as the first instruction of
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:[NSArray arrayWithObjects:@"fr", nil] forKey:@"AppleLanguages"];
[defaults synchronize];
It works fine except for one thing. When you launch the application for the first time after installation it's still in English. That's probably because AppleLanguages
preference was not yet set for it. After I quit the application and start it again it's being displayed correctly in French.
Does anyone knows a fix so that French language was applied also on the first run?
© Stack Overflow or respective owner