Jump to content

How to use unlocalized strings other than on item / block names?


Recommended Posts

Posted (edited)

I would like to have item information with addInformation() but have it localized.

I've tried with

tooltip.add(ChatFormatting.DARK_PURPLE + "descr.bonus.hoe");

but is not working

Edited by Insane96MCP
Posted

Either use a TextComponentTranslation or translate using I18n.

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.

Posted
1 minute ago, Kokkie said:

That's because you have

Which requires you to the color code in your lang file, remove it.

To make it have colors you put § + a number in front of the 'translation'.

Wrong. Tooltip entries are not translated when displayed, you have to do it yourself.

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.

Posted (edited)
2 minutes ago, Kokkie said:

But still, if he would pass it as a string to translate he would have to remove that, or make them seperate

No.

 

tooltip.add(TextFormatting.LIGHT_PURPLE + I18n.format("tooltip:oreflowers:indicator"));

Edited by Draco18s

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.

Posted
1 minute ago, Kokkie said:

That's what I ment with

Quote

or make them seperate

 


Oh no, the horror of having to use a + and concatenate a string!

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.

  • 2 weeks later...
Posted (edited)
On 20/10/2017 at 8:46 PM, Draco18s said:

No.

 

tooltip.add(TextFormatting.LIGHT_PURPLE + I18n.format("tooltip:oreflowers:indicator"));

Thanks everyone. I18n did the job. Another small question. How can I add a space after a string in the lang file? Like

tooltip.item.base_info=This is an OP sword <-Space

Seems like minecraft doesn't recognize the space.

Nevermind. I'm stupid. ^

The same question goes for a space after the equal (=)

tooltip.item.base_info= This is an OP sword

In this case, minecraft doesn't recognize the string at all.

 

I had to do

tooltip.add(I18n.format("tooltip.item.base_info") + " ");

and

tooltip.add(" " + I18n.format("tooltip.item.base_info"));

but I don't think that is a neat solution

Edited by Insane96MCP
I'm blind
Posted
31 minutes ago, diesieben07 said:

You should't need to have spaces at the beginning of your translation. Do not ever add translations together in code, always do it via the language file with placeholders.

Oh, forgot about placeholders.

Posted
35 minutes ago, diesieben07 said:

You should't need to have spaces at the beginning of your translation. Do not ever add translations together in code, always do it via the language file with placeholders.

There's any convention I should use for placeholders?

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.