I18nManager is used to manage internationalization settings in your app, particularly for Right-to-Left (RTL) language support.
Properties
isRTL
doLeftAndRightSwapInRTL
true.
When true, styles like marginLeft automatically become marginRight in RTL mode.
Example:
Methods
getConstants()
isRTL: Whether RTL is enableddoLeftAndRightSwapInRTL: Whether left/right swapping is enabledlocaleIdentifier: The current locale identifier (if available)
allowRTL()
shouldAllow:trueto enable RTL,falseto disable
forceRTL()
shouldForce:trueto force RTL,falseto use locale default
swapLeftAndRightInRTL()
marginLeft and marginRight are automatically flipped in RTL mode. Requires app restart to take effect.
Parameters:
flipStyles:trueto enable automatic flipping,falseto disable
Usage Example
Enabling RTL Support
In your app’s entry file (e.g.,index.js):
Conditional Styling Based on RTL
Testing RTL During Development
Using Start/End Instead of Left/Right
Instead ofmarginLeft and marginRight, you can use logical properties:
Platform Support
RTL support is available on:- iOS: Full support
- Android: Full support (API 17+)
- Web: Relies on CSS
dirattribute and browser support
Important Notes
-
App Restart Required: All configuration methods (
allowRTL,forceRTL,swapLeftAndRightInRTL) require a full app restart to take effect. -
Automatic Flipping: When
doLeftAndRightSwapInRTListrue(default), the following style properties are automatically flipped:marginLeft↔marginRightpaddingLeft↔paddingRightleft↔rightborderLeftWidth↔borderRightWidth- etc.
-
Prefer Start/End: For new code, prefer using
StartandEndvariants instead ofLeftandRightfor better RTL support. -
Testing: Use
forceRTL(true)during development to test RTL layouts without changing your device language.