Setting default language for iPhone app on first run

后端 未结 2 558
攒了一身酷
攒了一身酷 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.

提交回复
热议问题