Merge pull request #89 from davepack/patch-1

Fixes LocaleList not supported below API level 24
This commit is contained in:
Mathieu Acthernoene 2017-06-09 11:06:23 +02:00 committed by GitHub
commit 98c5c878a8
1 changed files with 8 additions and 6 deletions

View File

@ -42,15 +42,17 @@ public class RNI18nModule extends ReactContextBaseJavaModule {
}
private WritableArray getLocaleList() {
LocaleList locales = Build.VERSION.SDK_INT >= Build.VERSION_CODES.N
? getReactApplicationContext().getResources().getConfiguration().getLocales()
: new LocaleList(getReactApplicationContext().getResources().getConfiguration().locale);
WritableArray array = Arguments.createArray();
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
LocaleList locales = getReactApplicationContext().getResources().getConfiguration().getLocales();
for (int i = 0; i < locales.size(); i++) {
array.pushString(this.toLanguageTag(locales.get(i)));
}
} else {
array.pushString(this.toLanguageTag(getReactApplicationContext().getResources().getConfiguration().locale));
}
return array;
}