mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-30 16:19:03 +01:00
This commit is contained in:
parent
20e45f7315
commit
4433d23cc1
1 changed files with 8 additions and 2 deletions
|
@ -525,6 +525,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
+import net.kyori.adventure.text.serializer.plain.PlainComponentSerializer;
|
||||
+import net.kyori.adventure.translation.GlobalTranslator;
|
||||
+import net.kyori.adventure.translation.TranslationRegistry;
|
||||
+import net.kyori.adventure.translation.Translator;
|
||||
+import net.kyori.adventure.util.Codec;
|
||||
+import net.minecraft.ChatFormatting;
|
||||
+import net.minecraft.locale.Language;
|
||||
|
@ -547,8 +549,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ public static final ComponentFlattener FLATTENER = ComponentFlattener.basic().toBuilder()
|
||||
+ .complexMapper(TranslatableComponent.class, (translatable, consumer) -> {
|
||||
+ if (!Language.getInstance().has(translatable.key())) {
|
||||
+ consumer.accept(GlobalTranslator.render(translatable, Locale.US));
|
||||
+ return;
|
||||
+ for (final Translator source : GlobalTranslator.get().sources()) {
|
||||
+ if (source instanceof TranslationRegistry registry && registry.contains(translatable.key())) {
|
||||
+ consumer.accept(GlobalTranslator.render(translatable, Locale.US));
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ final @NonNull String translated = Language.getInstance().getOrDefault(translatable.key());
|
||||
+
|
||||
|
|
Loading…
Reference in a new issue