mirror of
https://github.com/status-im/react-native-i18n.git
synced 2025-01-09 11:45:54 +00:00
Fixes LocaleList not supported below API level 24
Modifies WritableArray method so that LocaleList is not needed on devices with lower than API level 24.
This commit is contained in:
parent
8e22064009
commit
5e940eeab1
@ -42,14 +42,16 @@ public class RNI18nModule extends ReactContextBaseJavaModule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private WritableArray getLocaleList() {
|
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();
|
WritableArray array = Arguments.createArray();
|
||||||
|
|
||||||
for (int i = 0; i < locales.size(); i++) {
|
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
|
||||||
array.pushString(this.toLanguageTag(locales.get(i)));
|
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;
|
return array;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user