Jump to content

Recommended Posts

Posted

Basically, i want to send messages to client in the language it's using.

Letting client translate unlocalized string is not an option, because mod will be server-sided.

 

PS. Forge 1307.

Posted

I think you'd need at least something on the client side to do this.  In Java I think you can use the Locale class to get information on the system's local, but that would have to be run on the client.

Then it's easier to let clients translate stuff.

Posted

Yes, if you're going to need the mod on the client side then using regular .lang localization would be easiest way.

But I don't want the mod to be on client. Like bukkit plugin, but written on forge.

 

For chat messages Mojang has already implement this, send a ChatComponentTranslation.

If i use ChatComponentTranslation and give it unlocalized name, wouldn't client print.... unlocalized name? because he doesn't know, how to localize it.

Or maybe it will localize it, but to server's locale?

I think i'll test it tomorrow.

 

PS. cpw wanted to allow servers to get client's locale. I don't know, if he did it or not.

https://github.com/MinecraftForge/FML/issues/258#issuecomment-32574938

Posted

That's what ChatComponentTranslation is for. It tells the client: "don't print this, translate it first".

And if client doesn't know how to translate it since it doesn't have the mod installed? Will server do it based on client's locale?

Posted

No, then the client will display it unlocalized.

 

That's the problem. I want to localize messages on server side based on client's language. And I don't know if I can do that at all.

Posted

public void func_147100_a(C15PacketClientSettings p_147100_1_) {
this.translator = p_147100_1_.getLang();

 

C15PacketClientSettings is made in GameSettings.sendSettingsToServer(S01PacketJoinGame packetIn) which is called from NetHandlerPlayClient.handleJoinGame as well as GameOptions.saveOptions()

Posted

EntityPlayerMP has

 

private String translator = "en_US";

 

It's private so either ASM/Reflection to get it, there's no getter method for it.

That's exactly what I wanted. Going to test it tomorrow, now it's 1am for me

Posted

61352151511

Thanks, that removes one packet and command from my mod :)

The more you know.

 

First time I saw someone correcting Diesieben :o

1.7.10 is no longer supported by forge, you are on your own.

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.