Connect the OS language with isRTL

Summary: Create isDeviceLanguageRTL function to connect the OS language with isRTL. Now even if a new app could support RTL language, without setting forceRTL at JS side it won't directly change into RTL layout.

Reviewed By: fkgozali

Differential Revision: D3473109

fbshipit-source-id: ac1410c910e980d44750bb88cad7615febb9e076
This commit is contained in:
Mengjue Wang 2016-06-23 18:54:01 -07:00 committed by Facebook Github Bot 0
parent 167654248b
commit fa6022dc1a
1 changed files with 9 additions and 1 deletions

View File

@ -24,7 +24,9 @@
- (BOOL)isRTL
{
if ([self forceRTL]) return YES;
if ([self forceRTL] && [self isDevicePreferredLanguageRTL]) {
return YES;
}
return NO;
}
@ -41,4 +43,10 @@
[[NSUserDefaults standardUserDefaults] synchronize];
}
- (BOOL)isDevicePreferredLanguageRTL
{
NSLocaleLanguageDirection direction = [NSLocale characterDirectionForLanguage:[[NSLocale preferredLanguages] objectAtIndex:0]];
return direction == NSLocaleLanguageDirectionRightToLeft;
}
@end