This commit is contained in:
@@ -525,6 +525,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
+import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
+import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||||
+import net.kyori.adventure.text.serializer.plain.PlainComponentSerializer;
|
+import net.kyori.adventure.text.serializer.plain.PlainComponentSerializer;
|
||||||
+import net.kyori.adventure.translation.GlobalTranslator;
|
+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.kyori.adventure.util.Codec;
|
||||||
+import net.minecraft.ChatFormatting;
|
+import net.minecraft.ChatFormatting;
|
||||||
+import net.minecraft.locale.Language;
|
+import net.minecraft.locale.Language;
|
||||||
@@ -547,9 +549,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
+ public static final ComponentFlattener FLATTENER = ComponentFlattener.basic().toBuilder()
|
+ public static final ComponentFlattener FLATTENER = ComponentFlattener.basic().toBuilder()
|
||||||
+ .complexMapper(TranslatableComponent.class, (translatable, consumer) -> {
|
+ .complexMapper(TranslatableComponent.class, (translatable, consumer) -> {
|
||||||
+ if (!Language.getInstance().has(translatable.key())) {
|
+ if (!Language.getInstance().has(translatable.key())) {
|
||||||
|
+ for (final Translator source : GlobalTranslator.get().sources()) {
|
||||||
|
+ if (source instanceof TranslationRegistry registry && registry.contains(translatable.key())) {
|
||||||
+ consumer.accept(GlobalTranslator.render(translatable, Locale.US));
|
+ consumer.accept(GlobalTranslator.render(translatable, Locale.US));
|
||||||
+ return;
|
+ return;
|
||||||
+ }
|
+ }
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
+ final @NonNull String translated = Language.getInstance().getOrDefault(translatable.key());
|
+ final @NonNull String translated = Language.getInstance().getOrDefault(translatable.key());
|
||||||
+
|
+
|
||||||
+ final Matcher matcher = LOCALIZATION_PATTERN.matcher(translated);
|
+ final Matcher matcher = LOCALIZATION_PATTERN.matcher(translated);
|
||||||
|
|||||||
Reference in New Issue
Block a user