package com.alexanderzaytsev.rn18n;

import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.module.annotations.ReactModule;

import java.util.HashMap;
import java.util.Map;

@ReactModule(name = "RNI18n")
public class RNI18nModule extends ReactContextBaseJavaModule {

  public RNI18nModule(ReactApplicationContext reactContext) {
    super(reactContext);
  }

  @Override
  public String getName() {
    return "RNI18n";
  }

  private String getCurrentLocale() {
    return getReactApplicationContext().getResources().getConfiguration().locale.toString();
  }

  @Override
  public Map<String, Object> getConstants() {
    HashMap<String,Object> constants = new HashMap<String,Object>();
    constants.put("locale", this.getCurrentLocale());
    return constants;
  }
}

@@ -30,16 +30,42 @@
 rn18n;%0A%0A
+import android.os.Build;%0A%0A
 import c
@@ -114,16 +114,16 @@
 ontext;%0A
-
 import c
@@ -581,84 +581,614 @@
     
-return getReactApplicationContext().getResources().getConfiguration().locale
+Locale currentLocale = (Build.VERSION.SDK_INT %3E= Build.VERSION_CODES.N)%0A      ? getReactApplicationContext().getResources().getConfiguration().getLocales().get(0)%0A      : getReactApplicationContext().getResources().getConfiguration().locale;%0A%0A    if (Build.VERSION.SDK_INT %3E= Build.VERSION_CODES.LOLLIPOP) %7B%0A      return currentLocale.toLanguageTag();%0A    %7D%0A%0A    StringBuilder builder = new StringBuilder();%0A    builder.append(currentLocale.getLanguage());%0A%0A    if (currentLocale.getCountry() != null) %7B%0A      builder.append(%22-%22);%0A      builder.append(currentLocale.getCountry());%0A    %7D%0A%0A    return builder
 .toS

Improve android language detection