Skip to content

fix(android): use the active locale to detect RTL direction#57635

Open
zoontek wants to merge 2 commits into
react:mainfrom
zoontek:fix-android-is-rtl
Open

fix(android): use the active locale to detect RTL direction#57635
zoontek wants to merge 2 commits into
react:mainfrom
zoontek:fix-android-is-rtl

Conversation

@zoontek

@zoontek zoontek commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Summary:

On Android, RTL detection read the wrong locale. isDevicePreferredLanguageRTL use Locale.getAvailableLocales()[0], which returns an arbitrary entry from the unordered list of all runtime locales (so, all locales that the current Android version supports), not the user's current system / app language. So layout direction was resolved from whatever locale happened to be first in that list, unrelated to the device (or per-app) language.

This fixes it to read the active locale from context.resources.configuration.locales[0], the resolved preferred locale for the app.

See the screenshots below: Locale.getAvailableLocales()[0] returns all locales supported by Android, so the first one is always af, and isRTL is always false:

Locale getAvailableLocales

vs context.resources.configuration.locales[0] for the same device language (I chose ar-JO in app settings), isRTL is true:

app locales

Changelog:

[ANDROID] [FIXED] - Detect RTL from the active locale instead of an arbitrary installed one

Test Plan:

Switch the device (or per-app) language to an RTL language (e.g. Arabic) and confirm the app lays out RTL.

Locale.getAvailableLocales()[0] (before, arbitrary):

android - before

context.resources.configuration.locales[0] (after, active locale):

android - after

@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 Jul 22, 2026
@facebook-github-tools facebook-github-tools Bot added 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. labels Jul 22, 2026
@meta-codesync

meta-codesync Bot commented Jul 22, 2026

Copy link
Copy Markdown

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

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. 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.

1 participant