Posted September 12, 20223 yr I've added a string to my lang my as follows: { "gui.<modid>.test": "Test percent sign {0}%%", } I'm then trying to render that string in a menu screen as follows: override fun render( stack: PoseStack, mouseX: Int, mouseY: Int, delta: Float ) { font.draw( stack, TranslatableComponent("gui.<modid>.test", 10) x, y 1 ) } However this akwardly results in string being rendered as: Test percent sign {0}% Is there any way to get percent sign to work with placeholders? Edited September 12, 20223 yr by H4kt wrong tabulation
September 12, 20223 yr You can try to use a backsplash before the %, or you add the % when creating the TranslatableComponent.
September 12, 20223 yr Translatable components only support String substitutions/formatting and minecraft uses the java.util.Formatter format. https://forge.gemwire.uk/wiki/Internationalization https://docs.oracle.com/javase/7/docs/api/java/util/Formatter.html Your lang file should look something like: Test percent sign %s%% Edited September 12, 20223 yr by warjort Boilerplate: If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one. If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install Large files should be posted to a file sharing site like https://gist.github.com You should also read the support forum sticky post.
September 12, 20223 yr Author 1 hour ago, warjort said: Translatable components only support String substitutions/formatting and minecraft uses the java.util.Formatter format. https://forge.gemwire.uk/wiki/Internationalization https://docs.oracle.com/javase/7/docs/api/java/util/Formatter.html Your lang file should look something like: Test percent sign %s%% Formatting like {n} also works, but not with percentage sign Replacing {0} with %s seems to work Thank you for your help
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.