mirror of
https://github.com/syncthing/syncthing-android.git
synced 2025-01-24 02:45:55 +00:00
Sort language names alphabetically and capitalize (fixes #935)
This commit is contained in:
parent
2f1d5f1ff2
commit
d3d00ff1d9
1 changed files with 8 additions and 2 deletions
|
@ -17,6 +17,7 @@ import com.nutomic.syncthingandroid.R;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -42,8 +43,13 @@ public final class Languages {
|
||||||
|
|
||||||
public Languages(Context context) {
|
public Languages(Context context) {
|
||||||
Map<String, String> tmpMap = new TreeMap<>();
|
Map<String, String> tmpMap = new TreeMap<>();
|
||||||
for (Locale locale : Arrays.asList(LOCALES_TO_TEST)) {
|
List<Locale> locales = Arrays.asList(LOCALES_TO_TEST);
|
||||||
tmpMap.put(locale.getLanguage(), locale.getDisplayLanguage(locale));
|
// Capitalize language names
|
||||||
|
Collections.sort(locales, (l1, l2) -> l1.getDisplayLanguage().compareTo(l2.getDisplayLanguage()));
|
||||||
|
for (Locale locale : locales) {
|
||||||
|
String displayLanguage = locale.getDisplayLanguage(locale);
|
||||||
|
displayLanguage = displayLanguage.substring(0, 1).toUpperCase() + displayLanguage.substring(1);
|
||||||
|
tmpMap.put(locale.getLanguage(), displayLanguage);
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove the current system language from the menu
|
// remove the current system language from the menu
|
||||||
|
|
Loading…
Reference in a new issue