From 86b0017138515065daf4ff0b7eda79ac3a6610ae Mon Sep 17 00:00:00 2001 From: Mathieu Acthernoene Date: Wed, 22 Jul 2026 16:15:57 +0200 Subject: [PATCH 1/2] fix(android): use the active locale to detect RTL direction --- .../react/modules/i18nmanager/I18nUtil.kt | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/i18nmanager/I18nUtil.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/i18nmanager/I18nUtil.kt index 38df17ec8cc4..475fdb12d9f4 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/i18nmanager/I18nUtil.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/i18nmanager/I18nUtil.kt @@ -11,7 +11,6 @@ import android.content.Context import android.content.pm.ApplicationInfo import android.view.View import androidx.core.text.TextUtilsCompat -import java.util.Locale public class I18nUtil private constructor() { /** @@ -20,8 +19,8 @@ public class I18nUtil private constructor() { * * allows RTL layout when using RTL locale */ public fun isRTL(context: Context): Boolean = - applicationHasRtlSupport(context) && - (isRTLForced(context) || (isRTLAllowed(context) && isDevicePreferredLanguageRTL)) + applicationHasRtlSupport(context) && + (isRTLForced(context) || (isRTLAllowed(context) && isDevicePreferredLanguageRTL(context))) /** * Android relies on the presence of `android:supportsRtl="true"` being set in order to resolve @@ -60,13 +59,12 @@ public class I18nUtil private constructor() { setPref(context, KEY_FOR_PREFS_FORCERTL, forceRTL) } - private val isDevicePreferredLanguageRTL: Boolean - // Check if the current device language is RTL - get() { - val directionality = - TextUtilsCompat.getLayoutDirectionFromLocale(Locale.getAvailableLocales()[0]) - return directionality == View.LAYOUT_DIRECTION_RTL - } + // Check if the current device language is RTL + private fun isDevicePreferredLanguageRTL(context: Context): Boolean { + val directionality = + TextUtilsCompat.getLayoutDirectionFromLocale(context.resources.configuration.locales[0]) + return directionality == View.LAYOUT_DIRECTION_RTL + } private fun isPrefSet(context: Context, key: String, defaultValue: Boolean): Boolean = context From 0262581a6c1bf1a9354f0ed5138c6f550143dc1a Mon Sep 17 00:00:00 2001 From: Mathieu Acthernoene Date: Wed, 22 Jul 2026 17:52:05 +0200 Subject: [PATCH 2/2] Run ktmft --- .../java/com/facebook/react/modules/i18nmanager/I18nUtil.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/i18nmanager/I18nUtil.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/i18nmanager/I18nUtil.kt index 475fdb12d9f4..1048e0b40062 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/i18nmanager/I18nUtil.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/i18nmanager/I18nUtil.kt @@ -19,8 +19,8 @@ public class I18nUtil private constructor() { * * allows RTL layout when using RTL locale */ public fun isRTL(context: Context): Boolean = - applicationHasRtlSupport(context) && - (isRTLForced(context) || (isRTLAllowed(context) && isDevicePreferredLanguageRTL(context))) + applicationHasRtlSupport(context) && + (isRTLForced(context) || (isRTLAllowed(context) && isDevicePreferredLanguageRTL(context))) /** * Android relies on the presence of `android:supportsRtl="true"` being set in order to resolve