Setting default language for iPhone app on first run

后端 未结 2 559
攒了一身酷
攒了一身酷 2020-12-11 13:30

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

相关标签:
2条回答
  • 2020-12-11 14:04

    I ran into the same issue, and the only way I could fix it was to have the piece of code at the earliest stage in the app, i.e. in main.c:

     int main(int argc, char *argv[]) {
    
         NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
    
         NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
         [defaults setObject:[NSArray arrayWithObjects:@"fr", nil] forKey:@"AppleLanguages"];
         [defaults synchronize];
    
         int retVal = UIApplicationMain(argc, argv, nil, nil);
    
         [pool release];
         return retVal;
     }
    

    I'm not really sure it's a good practice but it worked as expected in my case.

    0 讨论(0)
  • 2020-12-11 14:16

    Sounds messy. Why not just uncheck the unfinished English resources from the target, so they won't get deployed? Also, have you looked into the CFBundleDevelopmentRegion setting in Info.plist?

    0 讨论(0)
提交回复
热议问题