Skip to content

Conversation

@PRESIDENT810
Copy link

@PRESIDENT810 PRESIDENT810 commented Aug 21, 2025

Summary:

On iOS, if the default locale is not supported in the app, it will fall back to the first available locale to decide if RTL layout should be enabled or not; however on Android, we use the default locale. So if the first locale is a RTL locale and not supported by the app on Android, the app will fall back to the first available locale which might not be RTL, but the layout would be decided as RTL according to the default locale.

Changelog:

[ANDROID] [FIXED] - use the first available locale instead of the default one to decide isDevicePreferredLanguageRTL

Test Plan:

I set my phone's locale to this order: Hebrew, English and enabled RTL layout:

import { I18nManager } from 'react-native';

I18nManager.allowRTL(true);
I18nManager.swapLeftAndRightInRTL(true);

Prior to my PR, the app would use RTL layout with English on Android which doesn't make much sense (iOS is LTR + English). With my PR Android app will behave exactly the same as the iOS app.

…roid

Summary: on iOS, if the default locale is not supported in the app, it will fall back to the first available locale to decide if RTL layout should be enabled or not; however on Android, we use the default locale. So if the first locale is a RTL locale and not supported by the app on Android, the app will fall back to the first available locale which might not be RTL, but the layout would be decided as RTL according to the default locale.
@meta-cla
Copy link

meta-cla bot commented Aug 21, 2025

Hi @PRESIDENT810!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

@PRESIDENT810
Copy link
Author

(I just signed CLA

@meta-cla
Copy link

meta-cla bot commented Aug 21, 2025

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@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 Aug 21, 2025
@facebook-github-bot facebook-github-bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Aug 21, 2025
@facebook-github-bot
Copy link
Contributor

@zeyap has imported this pull request. If you are a Meta employee, you can view this in D80821903.

@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label Aug 28, 2025
@react-native-bot
Copy link
Collaborator

This pull request was successfully merged by Kaining Zhong in a03780d

When will my fix make it into a release? | How to file a pick request?

@facebook-github-bot
Copy link
Contributor

@zeyap merged this pull request in a03780d.

@mukti107
Copy link

this causes the issue, now changing the app language from englist to arabic still forces LTR instead of RTL.

Locale.getAvailableLocales()[0]
This gets the first locale in the list of ALL available locales installed on the device, not the current/preferred language. This is incorrect.

It should be using one of these instead:
Locale.getDefault() – the system's default locale
context.resources.configuration.locales[0] – the app's current locale (respects per-app language on Android 13+)

@PRESIDENT810
Copy link
Author

@mukti107 I'm terribly sorry. I made a new PR #54986 and changed to your proposed method to decide the directionality. Please take a look and confirm if that fix your issue. Thanks a lot!

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. Merged This PR has been merged. 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.

4 participants