Sort languages by name

This commit is contained in:
RaphiMC 2024-06-08 10:55:36 +02:00
parent 7f435382df
commit 9a8abdd9e0
No known key found for this signature in database
GPG Key ID: 0F6BB0657A03AC94

View File

@ -17,6 +17,9 @@
*/
package net.raphimc.viaproxy.ui;
import com.google.common.base.Functions;
import com.google.common.collect.ImmutableSortedMap;
import com.google.common.collect.Ordering;
import net.raphimc.viabedrock.api.util.FileSystemUtil;
import net.raphimc.viaproxy.ViaProxy;
@ -29,7 +32,7 @@ import java.util.*;
public class I18n {
private static final String DEFAULT_LOCALE = "en_US";
private static final Map<String, Properties> LOCALES = new HashMap<>();
private static Map<String, Properties> LOCALES = new LinkedHashMap<>();
private static String currentLocale;
static {
@ -46,6 +49,7 @@ public class I18n {
} catch (Throwable e) {
throw new RuntimeException("Failed to load translations", e);
}
LOCALES = ImmutableSortedMap.copyOf(LOCALES, Ordering.from(Comparator.comparing((Properties p) -> p.getProperty("language.name"))).onResultOf(Functions.forMap(LOCALES)));
currentLocale = ViaProxy.getSaveManager().uiSave.get("locale");
if (currentLocale == null || !LOCALES.containsKey(currentLocale)) {