Properly handle Norwegian locale code differences

Bedrock's code is not the same as Java's code.
This commit is contained in:
Camotoy 2021-09-29 14:49:20 -04:00
parent 3323e5732c
commit 59c34fbcae
No known key found for this signature in database
GPG key ID: 7EEFB66FE798081F

View file

@ -35,10 +35,7 @@ import org.geysermc.connector.GeyserConnector;
import java.io.*; import java.io.*;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.util.HashMap; import java.util.*;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import java.util.zip.ZipFile; import java.util.zip.ZipFile;
@ -119,7 +116,11 @@ public class LocaleUtils {
* @param locale Locale to download and load * @param locale Locale to download and load
*/ */
public static void downloadAndLoadLocale(String locale) { public static void downloadAndLoadLocale(String locale) {
locale = locale.toLowerCase(); locale = locale.toLowerCase(Locale.ROOT);
if (locale.equals("nb_no")) {
// Different locale code - https://minecraft.fandom.com/wiki/Language
locale = "no_no";
}
// Check the locale isn't already loaded // Check the locale isn't already loaded
if (!ASSET_MAP.containsKey("minecraft/lang/" + locale + ".json") && !locale.equals("en_us")) { if (!ASSET_MAP.containsKey("minecraft/lang/" + locale + ".json") && !locale.equals("en_us")) {
@ -225,8 +226,14 @@ public class LocaleUtils {
langMap.put(entry.getKey(), entry.getValue().asText()); langMap.put(entry.getKey(), entry.getValue().asText());
} }
String bedrockLocale = locale.toLowerCase(Locale.ROOT);
if (bedrockLocale.equals("no_no")) {
// Store this locale under the Bedrock locale so we don't need to do this check over and over
bedrockLocale = "nb_no";
}
// Insert the locale into the mappings // Insert the locale into the mappings
LOCALE_MAPPINGS.put(locale.toLowerCase(), langMap); LOCALE_MAPPINGS.put(bedrockLocale, langMap);
try { try {
localeStream.close(); localeStream.close();