Skip to content

Commit

Permalink
Sort language map using stream API instead of guava
Browse files Browse the repository at this point in the history
  • Loading branch information
RaphiMC committed Jun 15, 2024
1 parent 62b7030 commit 9e85832
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/main/java/net/raphimc/viaproxy/ui/I18n.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@
*/
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;

Expand All @@ -28,6 +25,7 @@
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
import java.util.*;
import java.util.stream.Collectors;

public class I18n {

Expand All @@ -49,7 +47,9 @@ 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)));
LOCALES = LOCALES.entrySet().stream()
.sorted(Comparator.comparing(e -> e.getValue().getProperty("language.name")))
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (oldValue, newValue) -> newValue, LinkedHashMap::new));

currentLocale = ViaProxy.getSaveManager().uiSave.get("locale");
if (currentLocale == null || !LOCALES.containsKey(currentLocale)) {
Expand Down

0 comments on commit 9e85832

Please sign in to comment.