Fixed translations preferring secondary locale over english
In the case where a non-standard region has been set for the primary system language, the secondary locale will be used for localized strings when available instead of the expected primary language. For example, set system locales to [en-SE, ja-JP], that is English with region Sweden, and Japanese with region Japan, most apps will display English descriptions but those which have a Japanese translation will display that instead. This commit adds a fallback case for when the primary locale has not matched any translations, but it's language part does.
This commit is contained in:
parent
c8dcb6260c
commit
87d4779c2d
@ -534,6 +534,15 @@ public class App extends ValueObject implements Comparable<App>, Parcelable {
|
||||
if (availableLocales.contains(languageTag)) {
|
||||
localesToUse.add(languageTag);
|
||||
}
|
||||
if (localesToUse.isEmpty()) {
|
||||
// In case of non-standard region like [en-SE]
|
||||
for (String availableLocale : availableLocales) {
|
||||
String availableLanguage = availableLocale.split("-")[0];
|
||||
if (languageTag.equals(availableLanguage)) {
|
||||
localesToUse.add(availableLocale);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (Build.VERSION.SDK_INT >= 24) {
|
||||
LocaleList localeList = Resources.getSystem().getConfiguration().getLocales();
|
||||
String[] sortedLocaleList = localeList.toLanguageTags().split(",");
|
||||
|
Loading…
x
Reference in New Issue
Block a user