run textcomponenttranslations through the ForgeI18N message format translator as well.

This commit is contained in:
cpw 2018-10-05 22:21:30 -04:00
parent e199e78a4f
commit 43ed744d46
2 changed files with 31 additions and 0 deletions

View File

@ -0,0 +1,13 @@
--- a/net/minecraft/util/text/TextComponentTranslation.java
+++ b/net/minecraft/util/text/TextComponentTranslation.java
@@ -101,6 +101,10 @@
}
}
+ if (j == 0) {
+ // if we failed to match above, lets try the messageformat handler instead.
+ j = net.minecraftforge.fml.TextComponentMessageFormatHandler.handle(this, this.field_150278_b, this.field_150277_e, p_150269_1_);
+ }
if (j < p_150269_1_.length()) {
ITextComponent itextcomponent1 = new TextComponentString(String.format(p_150269_1_.substring(j)));
itextcomponent1.func_150256_b().func_150221_a(this.func_150256_b());

View File

@ -0,0 +1,18 @@
package net.minecraftforge.fml;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentString;
import net.minecraft.util.text.TextComponentTranslation;
import java.util.List;
public class TextComponentMessageFormatHandler {
public static int handle(final TextComponentTranslation parent, final List<ITextComponent> children, final Object[] formatArgs, final String format) {
try {
children.add(new TextComponentString(ForgeI18n.parseFormat(format, formatArgs)));
return format.length();
} catch (IllegalArgumentException ex) {
return 0;
}
}
}