tutorial:lang
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
tutorial:lang [2019/07/24 12:31] – fudge | tutorial:lang [2019/07/24 16:43] – Adding a new line fudge | ||
---|---|---|---|
Line 26: | Line 26: | ||
@Override | @Override | ||
public void appendTooltip(ItemStack itemStack, World world, List< | public void appendTooltip(ItemStack itemStack, World world, List< | ||
- | tooltip.add(new TranslatableText(" | + | tooltip.add(new TranslatableText(" |
} | } | ||
</ | </ | ||
Line 33: | Line 33: | ||
<code JavaScript resources/ | <code JavaScript resources/ | ||
{ | { | ||
- | " | + | "item.tutorial.fabric_item.tooltip": "My Tooltip" |
} | } | ||
</ | </ | ||
And the tooltip will be displayed as "My Tooltip" | And the tooltip will be displayed as "My Tooltip" | ||
+ | |||
+ | ==== Adding dynamic values to translatable text ==== | ||
+ | Say you want the text to change based on some variable, like the current day and month. | ||
+ | For a dynamic number, we put a %d where you want the number to show in the lang entry value, for example: | ||
+ | <code JavaScript resources/ | ||
+ | { | ||
+ | " | ||
+ | } | ||
+ | </ | ||
+ | Then we pass the variables we use in our string by the order it appears in the text. First the day, then the month: | ||
+ | <code java> | ||
+ | int currentDay = 4; | ||
+ | int currentMonth = 7; | ||
+ | tooltip.add(new TranslatableText(" | ||
+ | </ | ||
+ | |||
+ | And the tooltip will be displayed as "My Tooltip in day 4, and month 7" | ||
+ | In order to pass a string, we use '' | ||
+ | For more information, | ||
+ | |||
+ | ==== Adding a new line ==== | ||
+ | Making '' | ||
+ | <code JavaScript resources/ | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | </ | ||
+ | Then add the '' | ||
+ | <code java> | ||
+ | tooltip.add(new TranslatableText(" | ||
+ | tooltip.add(new TranslatableText(" | ||
+ | </ | ||
+ | And the tooltip will be displayed as: | ||
+ | < | ||
+ | Line 1 of my tooltip | ||
+ | Line 2 of my tooltip | ||
+ | </ | ||
====== Translation format ====== | ====== Translation format ====== |
tutorial/lang.txt · Last modified: 2024/02/06 10:26 by rawdiamondmc