Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Switching between localized storyboard at runtime

I have iPhone application using storyboard with two language (Arabic / English) how i can switch from Arabic localization storyboard to English storyboard without need to change language iPhone settings (At run time)

like image 955
wod Avatar asked Jan 10 '13 14:01

wod


1 Answers

I have resolved you can do it as the following below code :

 UIStoryboard *storyBoard;
 if ([language isEqualToString:@"ar"]) {
   lan = [[NSLocale preferredLanguages] objectAtIndex:0];
   storyBoard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone5Arabic" bundle:bnd];
 }
 else if([language isEqualToString:@"en"]) {
    NSLog(@"DDD ");
    lan = [[NSLocale preferredLanguages] objectAtIndex:20];
    storyBoard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone5English" bundle:bnd];
 }
 NSBundle *bnd = [NSBundle bundleWithPath:[[NSBundle mainBundle]pathForResource:lan ofType:@"lproj" ]];



UIViewController *initViewController = [storyBoard instantiateInitialViewController];
[self.window setRootViewController:initViewController];
like image 124
wod Avatar answered Nov 15 '22 13:11

wod