Skip to content

Fix wrong I18nManager.isRTL value on iOS#51648

Closed
scarlac wants to merge 1 commit into
react:mainfrom
scarlac:patch-i18n-rtl
Closed

Fix wrong I18nManager.isRTL value on iOS#51648
scarlac wants to merge 1 commit into
react:mainfrom
scarlac:patch-i18n-rtl

Conversation

@scarlac

@scarlac scarlac commented May 27, 2025

Copy link
Copy Markdown
Contributor

Summary:

Fixes #51647

Changelog:

[iOS] [Fixed] Fix wrong I18nManager.isRTL value on iOS

Test Plan:

Ran this change in English (US, LTR), Hebrew (RTL), and Arabic (RTL) to confirm that they appear correctly.

@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. labels May 27, 2025
@scarlac

scarlac commented May 27, 2025

Copy link
Copy Markdown
Contributor Author

Closing. It looks like this is a mix of poor Apple docs and a lack of comments in the code.
isApplicationPreferredLanguageRTL does indeed check for the language correctly, but it does so by intersecting the system preferred language with Xcode project defined "Localizations" aka .pbxproj file knownRegions = ( ....

So by default, I18nManager.isRTL will not work, including in RNTester, since that project does not specify RTL languages:
https://github.com/facebook/react-native/blob/main/packages/rn-tester/RNTesterPods.xcodeproj/project.pbxproj#L466

This is all unexpected, undocumented behavior, so it explains why many issues have been raised regarding the use of .forceRTL(true) not being applied immediately - it's not meant for production use.

@scarlac scarlac closed this May 27, 2025
@Saadnajmi

Saadnajmi commented May 27, 2025

Copy link
Copy Markdown
Contributor

Closing. It looks like this is a mix of poor Apple docs and a lack of comments in the code. isApplicationPreferredLanguageRTL does indeed check for the language correctly, but it does so by intersecting the system preferred language with Xcode project defined "Localizations" aka .pbxproj file knownRegions = ( ....

So by default, I18nManager.isRTL will not work, including in RNTester, since that project does not specify RTL languages: https://github.com/facebook/react-native/blob/main/packages/rn-tester/RNTesterPods.xcodeproj/project.pbxproj#L466

This is all unexpected, undocumented behavior, so it explains why many issues have been raised regarding the use of .forceRTL(true) not being applied immediately - it's not meant for production use.

You coouldd open a new PR to add more comments to the code 😄. Or maybe add more languages to RNTester, but that might be trickier if it messes with CI.

@scarlac

scarlac commented May 28, 2025

Copy link
Copy Markdown
Contributor Author

@Saadnajmi Exactly. I think we also need to add an official docs page as well, as I18nManager is a vital piece of RN's internal rendering, and it's widely being misused.

#51661

scarlac pushed a commit to scarlac/react-native-website that referenced this pull request May 28, 2025
Added to sidebar as well.
Related to react/react-native#51661 and react/react-native#51648
scarlac pushed a commit to scarlac/react-native-website that referenced this pull request May 28, 2025
Added to sidebar as well.
Related to react/react-native#51661 and react/react-native#51648
scarlac pushed a commit to scarlac/react-native-website that referenced this pull request May 28, 2025
Added to sidebar as well.
Related to react/react-native#51661 and react/react-native#51648
scarlac pushed a commit to scarlac/react-native-website that referenced this pull request Jun 3, 2025
Abbondanzo pushed a commit to react/react-native-website that referenced this pull request Jun 4, 2025
Added to sidebar as well.
Related to react/react-native#51661 and react/react-native#51648

Co-authored-by: Seph Soliman <sesoliman@tesla.com>
coado pushed a commit to coado/react-native-website that referenced this pull request Jun 30, 2025
Added to sidebar as well.
Related to react/react-native#51661 and react/react-native#51648

Co-authored-by: Seph Soliman <sesoliman@tesla.com>
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. 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.

I18nManager.isRTL incorrect

3 participants