firstly i worked on android and the RTL working good, i added the following code:
I18nUtil sharedI18nUtilInstance = I18nUtil.getInstance();
sharedI18nUtilInstance.setAllowRTL(context, true);
to MainActivity.java and
android:supportsRtl="true"
to AndroidManifest.xml
and in the js code:
I18nManager.forceRTL(true);
Now is the problem: i tried to set rtl on ios but its not working i added
// in AppDelegate.m
[[RCTI18nUtil sharedInstance] allowRTL:YES];
and
I18nManager.forceRTL(true);
in js code but all the text and flex are still ltr... what can i do?
In general, most components are already RTL-ready, for example: Left-to-Right Layout.
React Native combines the best parts of native development with React, a best-in-class JavaScript library for building user interfaces. Use a little—or a lot. You can use React Native today in your existing Android and iOS projects or you can create a whole new app from scratch.
How do I force RTL on Android? Go to Settings and open the Developer Options settings. Under the Drawing settings, make sure to makr the "Force RTL layout direction" option. Now enjoy using the big screen of your Android device with your left hand.
React Native is a JavaScript library based on ReactJS, which we use to build mobile apps using iOS and Android platforms. The advantage of React Native is that a single code allows you to create an application at once for two systems, iOS and Android. This is suitable for small applications or MVPs.
No need to add an RTL language to your project. just open your AppDelegate.m
file in yourProject/ios/YourProject/AppDelegate.m
take care not to open another file that similar to this with .h
extension
Now, add #import <React/RCTI18nUtil.h>
to the top of code like this:
#import "AppDelegate.h"
#import <React/RCTBridge.h>
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#import <React/RCTI18nUtil.h> <-- added here
Now restart and rebuild your application.
Now you can change the RTL direction of the whole app with I18nManager
easily.
import {I18nManager} from "react-native"
I18nManager.forceRTL(true) // false for LTR direction
You must add an RTL Language beside default one and it'll work , more info can be found here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With