From dcef202aab3d0646893d563abeb0828baf796782 Mon Sep 17 00:00:00 2001 From: Sriram Ramasubramanian Date: Mon, 15 Aug 2016 18:28:00 -0700 Subject: [PATCH] Pass in the locale identifier from Android Reviewed By: AaaChiuuu, achen1 Differential Revision: D3668583 fbshipit-source-id: f34b6e24d9ff4fa044d24f4133c9c85564a3f00f --- .../react/modules/i18nmanager/I18nManagerModule.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/i18nmanager/I18nManagerModule.java b/ReactAndroid/src/main/java/com/facebook/react/modules/i18nmanager/I18nManagerModule.java index feefb593c..14bb792f4 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/i18nmanager/I18nManagerModule.java +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/i18nmanager/I18nManagerModule.java @@ -9,6 +9,8 @@ package com.facebook.react.modules.i18nmanager; +import android.content.Context; + import com.facebook.react.bridge.NativeModule; import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.bridge.ReactContext; @@ -16,6 +18,7 @@ import com.facebook.react.bridge.ReactContextBaseJavaModule; import com.facebook.react.bridge.ReactMethod; import com.facebook.react.common.MapBuilder; +import java.util.Locale; import java.util.Map; @@ -37,10 +40,14 @@ public class I18nManagerModule extends ReactContextBaseJavaModule { @Override public Map getConstants() { + final Context context = getReactApplicationContext().getBaseContext(); + final Locale locale = context.getResources().getConfiguration().locale; + final Map constants = MapBuilder.newHashMap(); constants.put("isRTL", sharedI18nUtilInstance.isRTL( getReactApplicationContext() )); + constants.put("localeIdentifier", locale.toString()); return constants; }