Fix locale names not shown correctly

This commit is contained in:
khanhduytran0
2020-11-21 16:06:06 +07:00
parent b13fb2bc32
commit bcb49e50bc
2 changed files with 15 additions and 3 deletions

View File

@@ -5,6 +5,19 @@ public class DisplayableLocale {
public final Locale mLocale;
public final CharSequence mName;
private static Locale processStringLocale(String locale) {
if (locale.contains("-")) {
String[] split = locale.split("-");
return new Locale(split[0], split[1]);
} else {
return new Locale(locale);
}
}
public DisplayableLocale(String locale) {
this(processStringLocale(locale));
}
public DisplayableLocale(Locale locale) {
this(locale, locale.getDisplayName(locale));
}

View File

@@ -217,8 +217,7 @@ public class PojavLoginActivity extends BaseActivity
System.out.println(currFile.getAbsolutePath());
if (currFile.getAbsolutePath().contains("/values-") || currFile.getName().startsWith("values-")) {
// TODO use regex(?)
Locale thisLocale = new Locale(currFile.getName().replace("values-", "").replace("-r", "-"));
langAdapter.add(new DisplayableLocale(thisLocale));
langAdapter.add(new DisplayableLocale(currFile.getName().replace("values-", "").replace("-r", "-")));
}
}
} catch (IOException e) {
@@ -248,7 +247,7 @@ public class PojavLoginActivity extends BaseActivity
Locale locale;
if (position == 0) {
locale = Locale.getDefault();
locale = LocaleUtils.DEFAULT_LOCALE;
} else if (position == 1) {
locale = Locale.ENGLISH;
} else {