fix(android): device language and region from system configuration. (#9868)

BREAKING CHANGE:

Exposes language and region values from android system configuration. If you were working around locale handling because this wasn't originally the case you can likely remove extra conditions as this should reflect more accurately now.
This commit is contained in:
Dimitris-Rafail Katsampas
2022-07-09 19:17:19 +03:00
committed by Nathan Walker
parent c9f77a0a22
commit ad01e6b990

View File

@@ -128,11 +128,23 @@ class DeviceRef {
}
get language(): string {
return java.util.Locale.getDefault().getLanguage().replace('_', '-');
let defaultNativeLocale;
if (android.os.Build.VERSION.SDK_INT >= 24) {
defaultNativeLocale = android.content.res.Resources.getSystem().getConfiguration().getLocales().get(0);
} else {
defaultNativeLocale = android.content.res.Resources.getSystem().getConfiguration().locale;
}
return defaultNativeLocale.getLanguage().replace('_', '-');
}
get region(): string {
return java.util.Locale.getDefault().getCountry();
let defaultNativeLocale;
if (android.os.Build.VERSION.SDK_INT >= 24) {
defaultNativeLocale = android.content.res.Resources.getSystem().getConfiguration().getLocales().get(0);
} else {
defaultNativeLocale = android.content.res.Resources.getSystem().getConfiguration().locale;
}
return defaultNativeLocale.getCountry();
}
}