From 74625a6f6d68cbd78ecbe204a2bb4c2d87ef3681 Mon Sep 17 00:00:00 2001 From: Alan Lee Date: Fri, 20 Feb 2026 17:20:08 -0800 Subject: [PATCH] Use ConfigurationCompat for locale access in I18nManagerModule Summary: Replace the direct `configuration.locales[0]` call with `ConfigurationCompat.getLocales()` from AndroidX, which handles the API level check internally. Falls back to `Locale.getDefault()` if the locale list is empty. Changelog: [Internal] ---- Differential Revision: D93943818 --- .../facebook/react/modules/i18nmanager/I18nManagerModule.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/i18nmanager/I18nManagerModule.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/i18nmanager/I18nManagerModule.kt index 461d2d30ab98..c52101536779 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/i18nmanager/I18nManagerModule.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/i18nmanager/I18nManagerModule.kt @@ -7,9 +7,11 @@ package com.facebook.react.modules.i18nmanager +import androidx.core.os.ConfigurationCompat import com.facebook.fbreact.specs.NativeI18nManagerSpec import com.facebook.react.bridge.ReactApplicationContext import com.facebook.react.module.annotations.ReactModule +import java.util.Locale /** [com.facebook.react.bridge.NativeModule] that allows JS to set allowRTL and get isRTL status. */ @ReactModule(name = NativeI18nManagerSpec.NAME) @@ -17,7 +19,8 @@ internal class I18nManagerModule(context: ReactApplicationContext?) : NativeI18nManagerSpec(context) { override fun getTypedExportedConstants(): Map { val context = reactApplicationContext - val locale = context.resources.configuration.locales[0] + val locale = + ConfigurationCompat.getLocales(context.resources.configuration)[0] ?: Locale.getDefault() return mapOf( "isRTL" to I18nUtil.instance.isRTL(context),