Codasylph Posted September 3, 2018 Share Posted September 3, 2018 (edited) In my mod there are a number of times when a message is sent to the player's chat to say something like "Good job you did this thing, now you can do this other thing!" or "That didn't quite work, you should make sure all the blocks are in the right place." I want this messages to able to be changed via the mod's lang files so that someone playing the game in spanish gets a message in spanish, english gets english, etc. Currently I do this by calling something like this on the server side: player.sendMessage(new TextComponentString(DemConstants.ALTAR_CREATED)); and the variable ALTAR_CREATED is defined like this: public static final String ALTAR_CREATED = I18n.format("text.altar_created.message"); and the string "text.altar_created.message" is in my .lang file as whatever I actually want it to be. I currently only have a US English version, but I'm trying to plan ahead. This all works just dandy in single player mode, but when I attempt to run it on a dedicated server I get a NoClassDef error because I18n is client side only. To my knowledge EntityPlayer#SendMessage is *supposed* to be called on the server side. So, clearly what I'm doing is wrong. What should I be doing? Edited September 3, 2018 by Codasylph Quote Link to comment Share on other sites More sharing options...
Draco18s Posted September 3, 2018 Share Posted September 3, 2018 Send the unlocalized text to the client and make the client translate it. That's the only way. Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given. Link to comment Share on other sites More sharing options...
Codasylph Posted September 3, 2018 Author Share Posted September 3, 2018 (edited) 26 minutes ago, Draco18s said: Send the unlocalized text to the client and make the client translate it. That's the only way. But.. but how? ? So, for anyone who stumbles across this thread in the future, I actually figured out how shortly after I made this post, proving that if i'd spent a few more minutes with google I would never have needed to post at all. If you use TextComponentTransation instead of TextComponentString it does the translating on the correct side. example: player.sendMessage(new TextComponentTranslation("text.altar_created.message")); No I18n or anything Edited September 3, 2018 by Codasylph Quote Link to comment Share on other sites More sharing options...
Cadiboo Posted September 4, 2018 Share Posted September 4, 2018 (edited) 18 hours ago, Draco18s said: Send the unlocalized text to the client and make the client translate it. That's the only way. 17 hours ago, Codasylph said: If you use TextComponentTransation instead of TextComponentString it does the translating on the correct side. example: player.sendMessage(new TextComponentTranslation("text.altar_created.message")); No I18n or anything This looks like your sending a message translated on the server (ie in the server’s language) to the client where it will appear in the sever’s language. Don’t do this, lang files exists for a reason Edited September 4, 2018 by Cadiboo Quote About Me Spoiler My Discord - Cadiboo#8887 My Website - Cadiboo.github.io My Mods - Cadiboo.github.io/projects My Tutorials - Cadiboo.github.io/tutorials Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support. When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible. Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme) Link to comment Share on other sites More sharing options...
V0idWa1k3r Posted September 4, 2018 Share Posted September 4, 2018 13 minutes ago, Cadiboo said: translated on the server (ie in the server’s language) The server has no concept of translation(or language at all for that matter). What OP did is the correct way. It send the lang key to the client and the client then translates it with the language the client has selected. Quote Link to comment Share on other sites More sharing options...
Cadiboo Posted September 4, 2018 Share Posted September 4, 2018 1 minute ago, V0idWa1k3r said: The server has no concept of translation(or language at all for that matter). What OP did is the correct way. It send the lang key to the client and the client then translates it with the language the client has selected. Really sorry, I read “new ITextComponentTranslation()” as “localise()” Quote About Me Spoiler My Discord - Cadiboo#8887 My Website - Cadiboo.github.io My Mods - Cadiboo.github.io/projects My Tutorials - Cadiboo.github.io/tutorials Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support. When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible. Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme) 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.