Skip to content

Rework I18nManager: runtime forceRTL, no left / right swap - #59404

Open
zoontek wants to merge 1 commit into
react:mainfrom
zoontek:i18nmanager-relayout
Open

zoontek wants to merge 1 commit into
react:mainfrom
zoontek:i18nmanager-relayout

Conversation

@zoontek

@zoontek zoontek commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

The RFC

Summary:

This is a proposal to simplify / cleanup I18nManager. It contains multiple breaking changes, and it's obviously open to discussion.

I started working on it as the current API is messy / hard to grasp:

  • RTL support has two switches on Android (android:supportsRtl in the manifest and allowRTL at runtime) but only one on iOS (allowRTL), so the platforms do not match.
  • allowRTL, forceRTL and swapLeftAndRightInRTL are saved to disk and only take effect after a restart. They act as app configuration written from JS.
  • The left / right swap is on by default and has no equivalent on the web, where margin-left stays on the left in RTL and only logical properties (margin-inline-start) follow the direction.

This PR:

  • Makes forceRTL apply at runtime: surfaces relayout, and isRTL updates immediately (bridgeless only). The value is no longer persisted.
  • Removes the left / right swap. left / right are always physical, like on the web. Use start / end for direction-aware styles (already supported for a while).
  • Reads RTL support from app configuration: new RCTSupportsRTL in Info.plist on iOS, android:supportsRtl on Android (unchanged). true by default.
  • Deprecates allowRTL, swapLeftAndRightInRTL and doLeftAndRightSwapInRTL (no-ops with a warning).

Changelog:

[GENERAL] [BREAKING] - I18nManager: forceRTL applies at runtime and is no longer persisted, left / right styles are no longer swapped in RTL, allowRTL and swapLeftAndRightInRTL are deprecated
[IOS] [BREAKING] - RTL requires RCTSupportsRTL set to true in Info.plist

Test Plan:

Commands I ran, and their results:

  • yarn flow-check: 0 errors
  • yarn build-types && yarn test-generated-typescript: passed
  • yarn test packages/react-native/Libraries packages/jest-preset: passed
  • python -m scripts.cxx-api.parser --validate: all snapshots match
  • yarn format-check-cpp, yarn format-check-kotlin: clean

Videos:

RNTester's RTL example toggles forceRTL without a reload:

RTL.-.Android.mp4
RTL.-.iOS.mp4

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Oct 23, 2026
@github-actions

Copy link
Copy Markdown

Warning

JavaScript API change detected

This PR commits an update to ReactNativeApi.d.ts, indicating a change to React Native's public JavaScript API.

  • Please include a clear changelog message.
  • This change will be subject to additional review.

This change was flagged as: POTENTIALLY_BREAKING

Comment thread packages/react-native/package.json Resolved
@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Oct 23, 2026
@zoontek
zoontek force-pushed the i18nmanager-relayout branch 3 times, most recently from 6958723 to 7fc01f0 Compare November 10, 2026 12:01
meta-codesync Bot pushed a commit that referenced this pull request Nov 20, 2026
## Summary:

#59404 wants to stop swapping `left` / `right` in RTL, so direction-aware borders need all logical properties support.

`borderBlock*Color` is already supported, but `borderBlockWidth`, `borderBlockStartWidth` and `borderBlockEndWidth` are ignored. The inline equivalents don't exist.

This PR adds `borderBlockWidth`, `borderBlockStartWidth`, `borderBlockEndWidth`, `borderInlineWidth`, `borderInlineStartWidth`, `borderInlineEndWidth`, `borderInlineColor`, `borderInlineStartColor` and `borderInlineEndColor` support.

## Changelog:

[GENERAL] [ADDED] - Add `borderBlockWidth`, `borderBlockStartWidth`, `borderBlockEndWidth`, `borderInlineWidth`, `borderInlineStartWidth`, `borderInlineEndWidth`, `borderInlineColor`, `borderInlineStartColor` and `borderInlineEndColor` style props

## Test Plan:

Flow, TypeScript, Jest and the Android Kotlin compile pass. A local Fantom test checked layout in LTR / RTL, precedence, and view flattening.

An new "Logical Borders" example in RNTester's Border page:

<img width="345" height="670" alt="iOS" src="https://github.com/user-attachments/assets/b177c0cc-3353-4cb7-b77e-6ff8cdff286c" />

<img width="349" height="652" alt="Android" src="https://github.com/user-attachments/assets/7bc77924-b1cd-4f43-9a15-be575cae2e55" />

Differential Revision: D132538487

Pull Request resolved: #59996
@zoontek
zoontek force-pushed the i18nmanager-relayout branch from 7fc01f0 to ee2c648 Compare November 23, 2026 11:10
@zoontek
zoontek force-pushed the i18nmanager-relayout branch 2 times, most recently from 5737063 to ef03542 Compare November 25, 2026 17:30
@zoontek
zoontek force-pushed the i18nmanager-relayout branch from dc533b0 to cf247aa Compare December 1, 2026 14:22
@github-actions github-actions Bot added the Meta Review Required This PR is considered risky and requires Meta to import it to do more testing before merging. label Dec 1, 2026

@javache javache left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this change be safe if you have an older native client running a newer JS bundle?

@zoontek
zoontek force-pushed the i18nmanager-relayout branch from d2e01c5 to 06fb00e Compare December 1, 2026 14:41
@zoontek

zoontek commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

@javache Mostly

  • forceRTL returns void on older native, so JS only updates isRTL when the native call returns a boolean.
  • Older native still swaps left / right, so SafeAreaView keeps its inset compensation when getConstants().doLeftAndRightSwapInRTL is true (only sent by older native). It can be removed together with the deprecated APIs.

The rest is compatible: every method the new JS calls still exists on older native, and allowRTL / swapLeftAndRightInRTL become no-ops in JS, so older native keeps its last saved values.

@javache javache left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we split this into three PRs so each can be made backwards-compatible and tested independently?

  1. Style cleanup: Move directional styles to start/end without changing layout behaviour.
  2. Runtime forceRTL(): Update JS state only when native returns a boolean; preserve the legacy restart behaviour otherwise.
  3. Native RTL changes: Remove native mirroring, but keep reporting and honouring the swap flag in JS for older binaries. Otherwise, SafeAreaView can pad the wrong edge in RTL. Document the new iOS RCTSupportsRTL opt-in in this PR.

@zoontek

zoontek commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

@javache I can split it.

One change to the order: runtime forceRTL() relayouts existing surfaces, but the swap mutates props and can't be undone, so toggling at runtime would leave views swapped. I'll do:

  1. Style cleanup (start / end, no behavior change)
  2. Remove the native swap, keep honoring doLeftAndRightSwapInRTL in JS for older binaries, document RCTSupportsRTL
  3. Runtime forceRTL(), with JS updating isRTL only when native returns a boolean

Is it OK for you?

@javache

javache commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Sounds good, thanks!

@zoontek
zoontek force-pushed the i18nmanager-relayout branch from f9ad32c to c5a9586 Compare December 2, 2026 09:24
@zoontek
zoontek force-pushed the i18nmanager-relayout branch from c5a9586 to 0d7e079 Compare December 2, 2026 09:24
@zoontek

zoontek commented Dec 2, 2026

Copy link
Copy Markdown
Contributor Author

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Meta Review Required This PR is considered risky and requires Meta to import it to do more testing before merging. p: Expo Partner: Expo Partner Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants