Skip to content

Commit

Permalink
enable RTL layout by default for all apps
Browse files Browse the repository at this point in the history
Summary:
We're now enabling RTL layout by default assuming the app has the proper localized assets. Previously, this was disabled by default to minimize surprise. Apps that don't want this RTL support can still manually disable them by using `RCTI18nUtil.allowRTL(false)` (iOS) or `I18nUtil.allowRTL(false)` (android) in the apps start-up logic, as outlined in the blog post: http://facebook.github.io/react-native/blog/2016/08/19/right-to-left-support-for-react-native-apps.html

iOS Util function: https://github.com/facebook/react-native/blob/f0fb228ec76ed49e6ed6d786d888e8113b8959a2/React/Modules/RCTI18nUtil.m#L53
Android Util function: https://github.com/facebook/react-native/blob/380830e4aa212fb934d3fe82d971cb8a316671f8/ReactAndroid/src/main/java/com/facebook/react/modules/i18nmanager/I18nUtil.java#L63

Differential Revision: D3825054

fbshipit-source-id: 88b355fef9e3847939a414f80d2285979e27af08
  • Loading branch information
fkgozali authored and Facebook Github Bot 2 committed Sep 7, 2016
1 parent e26c135 commit 96de161
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
9 changes: 6 additions & 3 deletions React/Modules/RCTI18nUtil.m
Expand Up @@ -42,12 +42,15 @@ - (BOOL)isRTL
/**
* Should be used very early during app start up
* Before the bridge is initialized
* @return whether the app allows RTL layout, default is true
*/
- (BOOL)isRTLAllowed
{
BOOL rtlStatus = [[NSUserDefaults standardUserDefaults]
boolForKey:@"RCTI18nUtil_allowRTL"];
return rtlStatus;
NSNumber *value = [[NSUserDefaults standardUserDefaults] objectForKey:@"RCTI18nUtil_allowRTL"];
if (value == nil) {
return YES;
}
return [value boolValue];
}

- (void)allowRTL:(BOOL)rtlStatus
Expand Down
Expand Up @@ -32,7 +32,7 @@ private I18nUtil() {
}

public static I18nUtil getInstance() {
if(sharedI18nUtilInstance == null) {
if (sharedI18nUtilInstance == null) {
sharedI18nUtilInstance = new I18nUtil();
}
return sharedI18nUtilInstance;
Expand All @@ -55,9 +55,10 @@ public boolean isRTL(Context context) {
/**
* Should be used very early during app start up
* Before the bridge is initialized
* @return whether the app allows RTL layout, default is true
*/
private boolean isRTLAllowed(Context context) {
return isPrefSet(context, KEY_FOR_PREFS_ALLOWRTL, false);
return isPrefSet(context, KEY_FOR_PREFS_ALLOWRTL, true);
}

public void allowRTL(Context context, boolean allowRTL) {
Expand Down

0 comments on commit 96de161

Please sign in to comment.