mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
parent
f83235cf96
commit
11c277481f
3 changed files with 24 additions and 2 deletions
|
@ -31,6 +31,7 @@ import org.geysermc.geyser.util.AssetUtils;
|
|||
import org.geysermc.geyser.util.FileUtils;
|
||||
import org.geysermc.geyser.util.WebUtils;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.*;
|
||||
import java.nio.file.Files;
|
||||
import java.util.HashMap;
|
||||
|
@ -208,6 +209,23 @@ public class MinecraftLocale {
|
|||
return localeStrings.getOrDefault(messageText, messageText);
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate the given language string into the given locale, or returns null.
|
||||
*
|
||||
* @param messageText Language string to translate
|
||||
* @param locale Locale to translate to
|
||||
* @return Translated string or null if it was not found in the given locale
|
||||
*/
|
||||
@Nullable
|
||||
public static String getLocaleStringIfPresent(String messageText, String locale) {
|
||||
Map<String, String> localeStrings = LOCALE_MAPPINGS.get(locale.toLowerCase(Locale.ROOT));
|
||||
if (localeStrings != null) {
|
||||
return localeStrings.get(messageText);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a byte array into a hex string
|
||||
*
|
||||
|
|
|
@ -45,7 +45,11 @@ public class MinecraftTranslationRegistry extends TranslatableComponentRenderer<
|
|||
@Override
|
||||
public @Nullable MessageFormat translate(@Nonnull String key, @Nonnull String locale) {
|
||||
// Get the locale string
|
||||
String localeString = MinecraftLocale.getLocaleString(key, locale);
|
||||
String localeString = MinecraftLocale.getLocaleStringIfPresent(key, locale);
|
||||
if (localeString == null) {
|
||||
// Allow fallback components to take priority
|
||||
return null;
|
||||
}
|
||||
|
||||
// Replace the `%s` with numbered inserts `{0}`
|
||||
Pattern p = stringReplacement;
|
||||
|
|
|
@ -13,7 +13,7 @@ protocol = "3.0.0.Beta1-SNAPSHOT"
|
|||
raknet = "0.0.1.Final-SNAPSHOT"
|
||||
mcauthlib = "d9d773e"
|
||||
mcprotocollib = "1.19.4-math2-SNAPSHOT"
|
||||
adventure = "4.12.0-20220629.025215-9"
|
||||
adventure = "4.13.1-20230408.192716-3"
|
||||
adventure-platform = "4.1.2"
|
||||
junit = "5.9.2"
|
||||
checkerframework = "3.19.0"
|
||||
|
|
Loading…
Reference in a new issue