Jump to content

[1.7.10] Get client's locale


Meegoo

Recommended Posts

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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()

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.