I am Developing an app which supports two languages i.e English and Arabic. I have done mostly all tasks i.e localisation within app + handle UI LTR (english language) , RTL (Arabic language).
Now I want to see preview for a UI in RTL in storyboard. By default it is LTR.
What I have done till now:
+(void)initialize {
NSUserDefaults* defs = [NSUserDefaults standardUserDefaults];
NSArray* languages = [defs objectForKey:@"AppleLanguages"];
NSString *current = [languages objectAtIndex:0];
[self setLanguage:current];
}
+(void)setLanguage:(NSString *)l {
NSLog(@"\n\n\t ***** Hint Lang. selected by user: %@ ****\n\n", l);
NSString *path = [[ NSBundle mainBundle ] pathForResource:l ofType:@"lproj" ];
bundle = [NSBundle bundleWithPath:path];
}
+(NSString *)get:(NSString *)key alter:(NSString *)alternate {
return [bundle localizedStringForKey:key value:alternate table:nil];;
}
For handle UI LTR OR RTL. For example when user selects english language I set UI as
[UIView appearance].semanticContentAttribute = UISemanticContentAttributeForceLeftToRight;
and when user selects Arabic language then I set UI as
[UIView appearance].semanticContentAttribute = UISemanticContentAttributeForceRightToLeft;
But I have to check every and run app iPhone UI screen whether it is fine or not for both LTR as well as RTL.
Is there any way by which we can see preview UI as RTL in storyboard (without to run in iPhone/simulator). Any suggestion will be Great!! Thanks in advance!!