H4kt Posted September 12, 2022 Share Posted September 12, 2022 (edited) 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, 2022 by H4kt wrong tabulation Quote Link to comment Share on other sites More sharing options...
Luis_ST Posted September 12, 2022 Share Posted September 12, 2022 You can try to use a backsplash before the %, or you add the % when creating the TranslatableComponent. Quote Link to comment Share on other sites More sharing options...
warjort Posted September 12, 2022 Share Posted September 12, 2022 (edited) 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, 2022 by warjort Quote 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. Link to comment Share on other sites More sharing options...
H4kt Posted September 12, 2022 Author Share Posted September 12, 2022 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.