Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-12-25 15:50:14 +01:00
Allow fallback components to translate with arguments
Dieser Commit ist enthalten in:
Ursprung
48b796d75e
Commit
0f3d5c5859
@ -42,13 +42,23 @@ public class MinecraftTranslationRegistry extends TranslatableComponentRenderer<
|
||||
private final Pattern stringReplacement = Pattern.compile("%s");
|
||||
private final Pattern positionalStringReplacement = Pattern.compile("%([0-9]+)\\$s");
|
||||
|
||||
// Exists to maintain compatibility with Velocity's older Adventure version
|
||||
@Override
|
||||
public @Nullable MessageFormat translate(@Nonnull String key, @Nonnull String locale) {
|
||||
return this.translate(key, null, locale);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected @Nullable MessageFormat translate(@Nonnull String key, @Nullable String fallback, @Nonnull String locale) {
|
||||
// Get the locale string
|
||||
String localeString = MinecraftLocale.getLocaleStringIfPresent(key, locale);
|
||||
if (localeString == null) {
|
||||
// Allow fallback components to take priority
|
||||
return null;
|
||||
if (fallback == null) {
|
||||
// No fallback and no match for string; nothing will be translated/inserted
|
||||
return null;
|
||||
}
|
||||
// Fallback strings will still have their params inserted
|
||||
localeString = fallback;
|
||||
}
|
||||
|
||||
// Replace the `%s` with numbered inserts `{0}`
|
||||
|
@ -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.13.1-20230408.192716-3"
|
||||
adventure = "4.14.0-20230418.205641-5"
|
||||
adventure-platform = "4.1.2"
|
||||
junit = "5.9.2"
|
||||
checkerframework = "3.19.0"
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren