mirror of
https://github.com/status-im/react-native.git
synced 2025-02-25 07:35:25 +00:00
Provide function that could read app current using language
Summary: Provide function that could read the language currently used in the app, so the isRTL is using the app current using language to set isRTL. Reviewed By: fkgozali Differential Revision: D3480654 fbshipit-source-id: dea3ef4769296f594f7f32da2961b4fec1b99a7a
This commit is contained in:
parent
d055ab548e
commit
0e07c36794
@ -22,9 +22,11 @@
|
||||
return sharedRCTI18nUtilInstance;
|
||||
}
|
||||
|
||||
// If currnent using language is RTL language and meanwhile set forceRTL on the JS side,
|
||||
// the RN app will automatically have a RTL layout.
|
||||
- (BOOL)isRTL
|
||||
{
|
||||
if ([self forceRTL] && [self isDevicePreferredLanguageRTL]) {
|
||||
if ([self forceRTL] && [self isApplicationPreferredLanguageRTL]) {
|
||||
return YES;
|
||||
}
|
||||
return NO;
|
||||
@ -43,10 +45,19 @@
|
||||
[[NSUserDefaults standardUserDefaults] synchronize];
|
||||
}
|
||||
|
||||
// Check if the current device language is RTL
|
||||
- (BOOL)isDevicePreferredLanguageRTL
|
||||
{
|
||||
NSLocaleLanguageDirection direction = [NSLocale characterDirectionForLanguage:[[NSLocale preferredLanguages] objectAtIndex:0]];
|
||||
return direction == NSLocaleLanguageDirectionRightToLeft;
|
||||
}
|
||||
|
||||
// Check if the current application language is RTL
|
||||
- (BOOL)isApplicationPreferredLanguageRTL
|
||||
{
|
||||
NSString *preferredAppLanguage = [[[NSBundle mainBundle] preferredLocalizations] objectAtIndex:0];
|
||||
NSLocaleLanguageDirection direction = [NSLocale characterDirectionForLanguage:preferredAppLanguage];
|
||||
return direction == NSLocaleLanguageDirectionRightToLeft;
|
||||
}
|
||||
|
||||
@end
|
||||
|
Loading…
x
Reference in New Issue
Block a user