With Translate

We’re going to be able to make our lives easier. The tellraw translate feature is a scary beast. Disassociating actual text with references usually is. The translate feature has been severely underutilized since it’s introduction, and for good reason:

No one wants to make resource packs mandatory.

Under the 1.7 Minecraft idiom, resource packs often meant an extra installation step. Next to no one used the “resources.zip” feature. Whether this was due to a lack of understanding or outright awareness…we’ll probably never know. Come Minecraft 1.8, it’s our duty as map makers and indie game developers to make sure everyone knows it’s OK to use resource packs as an integral part of your custom map releases.

This is how we’re going to make resource packs easy for the players:

  • If you are releasing a single-player map, package your resource pack by including it within a zip file called “resources.zip” within your world save file. It should look like this: saves
  • If you release a multiplayer map, supply a direct download link for server operators so they may include it in the server.properties file under the “resource-pack=” option. This will automatically prompt any connecting players to automatically download the resource pack.

Now, you may be asking yourself, “Self, why do I need resource packs?”

Besides the awesome new block models, custom textures, sounds, and an extra level of crispy…resource packs allows you to simplify your tellraw lines. This is by using the “translate” and the “with” feature. I’m sure many of you have seen this:

tellraw {"text":"First text","extra":[{"text":" ("},{"text":"Clickable text"},{"text":") "}]}

What’s so important to note about this example? Well, other than the fact it may not work (haven’t checked it), you may notice there’s four areas of text, two of which are just brackets. Now let’s look at how this may work with the “translate” and the “with” feature:

tellraw {"translate":"example.first","with":[{"translate":"example.clicktext"}]}

This command includes only one call to superfluous text and then is followed only by text that requires different formatting, action events, or hover events. Not only is this a much shorter command, it’s also much more human readable.

Human readable is simply that: much easier on the eyes to read and scan. This command needs some extra work from us. Let’s go into our resource pack:

resourcepacks   This is the resource pack I’m using for all of my maps. While I’m developing maps, I keep it as a separate, unzipped file within my resourcepacks folder, and I’ll explain why in a bit. I’m going to use Notepad++ edit this file: enuslang

It’s important to note Minecraft will default to en_US.lang when it finds no other language file.

Let’s take a look at the first line:

example.first=First text (%1$s)

This line does a few interesting things:

  • It identifies an address for the “translate” feature to target, “example.first”
  • It allows you to write an entire tellraw line at once
  • Using %1$s, or just %s (string) or %d (integer), it will let you create blocks for other text, which allows you to split out functions without having to add a bunch of superfluous blocks for text

In our original command, we reference “example.first” in our first translate call and then, by using the “with” function, make a call to translate “example.clicktext”. Notice how there is no additional block. We make two simple calls, with no mucking about additional commas, brackets, or anything else. All the dressing up comes from en_US.lang–which is how Mojang handles all the text we see in Minecraft.

This separation is incredibly important.

By making these separations, we’re giving our projects the chance to be played by anyone in the world, and not just the English speaking community. Imagine someone playing your map and being having to have a great experience in their native language–without having to release a separate version of your map for every language. Using “translate” in our tellraw message, signs, and books, we’re allowing our maps to become a viable product for everyone in the world.

But Moesh, I don’t want to have to reload my resource pack every time I make a change.

Sure, it’s a pain the ass. Mojang made this easy for us. Just press F3+T to reload your resource pack while in game. While you develop your map, treat your resource pack as a separate entity. When it comes time to release, package it up (as resources.zip) for single player maps, and create a download link for multiplayer maps, and release it!

Translate streamlines your work, makes it easier for you to work with JSON, and prepares your map for a global marketplace.

It is undoubtedly a best practice to make the transition now. See you next week, Moesh

9 thoughts on “With Translate”

  1. I’m still a little bit unclear about one thing: If a player has his/her default language set to something other than English, does the map maker need to include a separate .lang file for that language in the resource pack, or will translate automatically change to their language?

        1. It will default to your customized en_US.lang for all custom messages, and use German for the rest of the words.

          This means you can add as many supported languages as you have translators for, but it won’t break the entire game if you don’t have someone’s specific language file.

  2. I must be dense. If the resource pack is by default US how is text changed for people that set their language differently?

    1. You need a separate file for every language e.g. de_DE.lang for german. I am not sure if they use the same fallback rules as java so if the language is de_AT (austrian german) I don’t know wether they will use de_DE or en_US.

Leave a Reply

Your email address will not be published. Required fields are marked *