tutorial:lang
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
tutorial:lang [2022/04/21 08:44] – [Adding dynamic values to translatable text] luckius974 | tutorial:lang [2024/02/06 10:26] (current) – minecraft wiki rawdiamondmc | ||
---|---|---|---|
Line 3: | Line 3: | ||
===== Creating a lang file ===== | ===== Creating a lang file ===== | ||
- | You can use lang files to provide translations for translatable strings in-game. You'll need to create a file with an appropriate file name for your language-- to find your languages' | + | You can use lang files to provide translations for translatable strings in-game. You'll need to create a file with an appropriate file name for your language-- to find your languages' |
===== Adding a translation ===== | ===== Adding a translation ===== | ||
Line 17: | Line 17: | ||
===== Using custom translatable text ===== | ===== Using custom translatable text ===== | ||
- | Whenever a function accepts ''< | + | Whenever a function accepts ''< |
which means minecraft will use the string in the constructor argument as-is. However, this is not advisable because | which means minecraft will use the string in the constructor argument as-is. However, this is not advisable because | ||
that would make it difficult to translate that text to another language, should you wish to do that. This is why | that would make it difficult to translate that text to another language, should you wish to do that. This is why | ||
- | whenever a ''< | + | whenever a ''< |
and then translate the key in the lang file. | and then translate the key in the lang file. | ||
For example, when adding a tooltip, do: | For example, when adding a tooltip, do: | ||
Line 26: | Line 26: | ||
@Override | @Override | ||
public void method_9568(class_1799 itemStack, class_1937 world, List< | public void method_9568(class_1799 itemStack, class_1937 world, List< | ||
+ | // 1.18.2 and before | ||
tooltip.add(new class_2588(" | tooltip.add(new class_2588(" | ||
+ | | ||
+ | // 1.19 and later | ||
+ | tooltip.add(Text.translatable(" | ||
} | } | ||
</ | </ | ||
Line 51: | Line 55: | ||
int currentDay = 4; | int currentDay = 4; | ||
int currentMonth = 7; | int currentMonth = 7; | ||
+ | |||
+ | // 1.18.2 and before: | ||
tooltip.add(new class_2588(" | tooltip.add(new class_2588(" | ||
+ | |||
+ | // 1.19 and later: | ||
+ | tooltip.add(Text.translatable(" | ||
</ | </ | ||
Line 68: | Line 77: | ||
Then add the ''< | Then add the ''< | ||
< | < | ||
- | tooltip.add(new new class_2588(" | + | // 1.18.2 and below: |
- | tooltip.add(new new class_2588(" | + | tooltip.add(new class_2588(" |
+ | tooltip.add(new class_2588(" | ||
+ | |||
+ | // 1.19 and later | ||
+ | tooltip.add(Text.translatable(" | ||
+ | tooltip.add(Text.translatable(" | ||
</ | </ | ||
And the tooltip will be displayed as: | And the tooltip will be displayed as: |
tutorial/lang.1650530697.txt.gz · Last modified: 2022/04/21 08:44 by luckius974