Skip to main content
I18nManager is used to manage internationalization settings in your app, particularly for Right-to-Left (RTL) language support.

Properties

isRTL

Indicates whether the current locale is RTL. Example:

doLeftAndRightSwapInRTL

Indicates whether left and right styles should be swapped in RTL layouts. Defaults to true. When true, styles like marginLeft automatically become marginRight in RTL mode. Example:

Methods

getConstants()

Returns the current i18n configuration constants. Returns:
  • isRTL: Whether RTL is enabled
  • doLeftAndRightSwapInRTL: Whether left/right swapping is enabled
  • localeIdentifier: The current locale identifier (if available)
Example:

allowRTL()

Enables or disables RTL layout support. Requires app restart to take effect. Parameters:
  • shouldAllow: true to enable RTL, false to disable
Example:

forceRTL()

Forces the app to use RTL layout regardless of the device locale. Requires app restart to take effect. Useful for testing RTL layouts during development. Parameters:
  • shouldForce: true to force RTL, false to use locale default
Example:

swapLeftAndRightInRTL()

Controls whether styles like marginLeft and marginRight are automatically flipped in RTL mode. Requires app restart to take effect. Parameters:
  • flipStyles: true to enable automatic flipping, false to disable
Example:

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 of marginLeft 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 dir attribute and browser support

Important Notes

  1. App Restart Required: All configuration methods (allowRTL, forceRTL, swapLeftAndRightInRTL) require a full app restart to take effect.
  2. Automatic Flipping: When doLeftAndRightSwapInRTL is true (default), the following style properties are automatically flipped:
    • marginLeft ↔ marginRight
    • paddingLeft ↔ paddingRight
    • left ↔ right
    • borderLeftWidth ↔ borderRightWidth
    • etc.
  3. Prefer Start/End: For new code, prefer using Start and End variants instead of Left and Right for better RTL support.
  4. Testing: Use forceRTL(true) during development to test RTL layouts without changing your device language.