mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-20 07:34:48 +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.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);
|
||||||
|
|
Loading…
Reference in a new issue