28 lines
1.6 KiB
Markdown
28 lines
1.6 KiB
Markdown
```
|
|
title = "Localization"
|
|
date = "2016-05-08 09:15:00 -0400"
|
|
```
|
|
|
|
If you'll recalled, we used the `setUnlocalizedName` method in both our `BlockBase` and `ItemBase` classes. The name that we passed into that method is what Minecraft uses when localizing the name of our block or item for the currently active language.
|
|
|
|
In these tutorials, we are only going to add English localizations however you can easily add more localizations by following the same pattern.
|
|
|
|
Language files are located at `src/main/resources/assets/tutorial/lang/IDENTIFIER.lang` where `IDENTIFIER` is the locale code of the language. Let's create a localization file with the identifier `en_us` (you can see a list of locale codes [here](https://minecraft.gamepedia.com/Language), but note that the file names do need to be entirely lowercase).
|
|
|
|
Language files are written in a simple `key=value` format with one entry per line. The `value` is obviously the translated name, this obviously differs for every language file. The `key` is the key that Minecraft uses when translating things. This is slightly different for blocks and items. For blocks the key is `tile.UNLOCALIZED.name`. For items the key is `item.UNLOCALIZED.name`. Where `UNLOCALIZED` is what we passed into `setUnlocalizedName`.
|
|
|
|
**Note:** Lines starting with `#` are comments and won't be parsed.
|
|
|
|
```plaintext
|
|
# Items
|
|
item.ingot_copper.name=Copper Ingot
|
|
|
|
# Blocks
|
|
tile.ore_copper.name=Copper Ore
|
|
```
|
|
|
|
Now, both our Copper Ore and Copper Ingot have properly localized names!
|
|
|
|
![Copper Ore Screenshot](https://i.imgur.com/f6T09kI.png)
|
|
![Copper Ingot Screenshot](https://i.imgur.com/oafpj5q.png)
|