flattener should try to render custom translations (#6540)
Dieser Commit ist enthalten in:
Ursprung
ca708a0944
Commit
f02d3d8989
@ -498,10 +498,10 @@ index 0000000000000000000000000000000000000000..eeedc30a45d9637d68f04f185b3dd90d
|
||||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/adventure/PaperAdventure.java b/src/main/java/io/papermc/paper/adventure/PaperAdventure.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..f63b80a1120b2bf5f77f1c1edb928309a1272f79
|
||||
index 0000000000000000000000000000000000000000..41762b5ed19b17ee524f79726eaa4cf38479ba96
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/adventure/PaperAdventure.java
|
||||
@@ -0,0 +1,370 @@
|
||||
@@ -0,0 +1,375 @@
|
||||
+package io.papermc.paper.adventure;
|
||||
+
|
||||
+import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
@ -527,6 +527,7 @@ index 0000000000000000000000000000000000000000..f63b80a1120b2bf5f77f1c1edb928309
|
||||
+import net.kyori.adventure.translation.GlobalTranslator;
|
||||
+import net.kyori.adventure.util.Codec;
|
||||
+import net.minecraft.ChatFormatting;
|
||||
+import net.minecraft.locale.Language;
|
||||
+import net.minecraft.nbt.CompoundTag;
|
||||
+import net.minecraft.nbt.ListTag;
|
||||
+import net.minecraft.nbt.StringTag;
|
||||
@ -545,7 +546,11 @@ index 0000000000000000000000000000000000000000..f63b80a1120b2bf5f77f1c1edb928309
|
||||
+ private static final Pattern LOCALIZATION_PATTERN = Pattern.compile("%(?:(\\d+)\\$)?s");
|
||||
+ public static final ComponentFlattener FLATTENER = ComponentFlattener.basic().toBuilder()
|
||||
+ .complexMapper(TranslatableComponent.class, (translatable, consumer) -> {
|
||||
+ final @NonNull String translated = net.minecraft.locale.Language.getInstance().getOrDefault(translatable.key());
|
||||
+ if (!Language.getInstance().has(translatable.key())) {
|
||||
+ consumer.accept(GlobalTranslator.render(translatable, Locale.US));
|
||||
+ return;
|
||||
+ }
|
||||
+ final @NonNull String translated = Language.getInstance().getOrDefault(translatable.key());
|
||||
+
|
||||
+ final Matcher matcher = LOCALIZATION_PATTERN.matcher(translated);
|
||||
+ final List<Component> args = translatable.args();
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren