I'm working on a app that supports multiple language. Everything is going well. But I need to change the language during runtime.
I'm doing it this way -
NSArray* languages = [NSArray arrayWithObjects:@"es",@"en" nil];
[[NSUserDefaults standardUserDefaults] setObject:languages forKey:@"AppleLanguages"];
[[NSUserDefaults standardUserDefaults] synchronize];
NSString *langID = [[NSLocale preferredLanguages] objectAtIndex:0];
To change the app language during runtime, I have done this manually by creating two different storyboards. I saved the language preference in
NSUserDefaults but NOT with the key
AppleLanguages and then called AppDelegate's
didFinishLaunchingWithOptions method to select storyboard.
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainEnglish" bundle:nil]; UINavigationController *navigationcontroller=[[UINavigationController alloc]init]; RegistorViewController *registor=[storyboard instantiateViewControllerWithIdentifier:@"Registor"]; [self.window setRootViewController:navigationcontroller]; [self.window makeKeyAndVisible]; [navigationvontroller pushViewController:registor animated:NO];