Do you want to make your map available in multiple languages? This tutorial outlines how to provide automatic, expandable localizations to your map on anything that uses text formatting. This includes signs, chat, books, and titles. Basically, you will make a language pack that translates every single line of text in your map and bundle it with your map.
1. Text Formatting
Before you start translating, you will need to understand the basics of text formatting in Minecraft. Text formatting is controlled using the syntax of the /tellraw command. If you are already familiar with this command, you know that text can be made bold, italic, underlined, strikethrough, and colored, as well as added click- and hover-events. Text formatting also has a less-known feature: translate. As described in 1.8 - Raw JSON Text Examples:
Language files can be accessed to display translatable text using the "translate" tag. The resulting output will be dependent on what language the viewer has selected. As usual, this replaces the "text" tag. Some translatable text require additional arguments to fill in blanks, in which the "with" list-tag will provide such text. The "with" tag, like "extra", is a list of text components. This means you can format the text to what you'd like, as well as inserting functions or using other alternative texts (such as displaying a score or player name, or even another translation). If arguments are not properly provided, the argument will be left blank instead.
The translate tag's value is a line in a language file, e.g. "tile.stone.name". This value is not limited to the default language translations, but can be anything, and the tag will accept and read custom lines from language files. As well as text formatting, the language files themselves allow for limited string formatting of variables. Language files accept:
%s (string)
%d (integer)
%f (float)
%% (literal percent)
Any formatter can also use "#$", the index of the "with" array used with the translate tag. You cannot specify additional number formatting such as alignment or precision, so it is best to always use %s. Use %s when you want to add player names, scores, and special click or hover events to your localized text. This allows maximal flexibility for your translation.
2. Test Case: Signs
By far signs are the classic method of communication in custom maps. Here is how to use text formatting on signs. First, place the sign where you want it to be (or not, you can always use the pick block +NBT feature). Then, instead of writing on it, use the /blockdata command to add the translate tag:
Note: Do not put quotes around Text1, Text2, Text3, or Text4.
You should put the default translation in the en_US.lang file. Set up a resource pack with a blank en_US.lang file (and nothing else!), and add the values of the translate tag to it. If you want the sign to say "Hello, I am speaking English!", you would write:
map.hello1=<br>map.hello2=Hello, I am<br>map.hello3=speaking English!<br>map.hello4=
When you load the map with the resource pack, the same sign new says:
If you want the sign to speak Spanish, place the same lines in the es_MX.lang file.
When you select Spanish (Mexican) as the language, the sign now says:
Of course, you will need to provide the translations.
3. Test Case: Books
You cannot write a localized book in the normal way. You must use the /give command to get a book with the title and author you want to be displayed. Book titles (and custom item names) are some of the few texts that cannot be formatted, so you will not be able to localize the book's title. Localizing the pages are done much like for signs; just use the translate tag. As an example:
Note: You must provide both a title and author for the book to be readable.
Simply write your translation in the language file and it will display in the book. Line breaks will be added automatically, but you will have to make sure that your translation does not overflow the page.
To forcibly insert line breaks, use "%1$s" where each line break will go and add "\n" to the first index of the "with" array.
4. Test Case: Chat
Chat is the easiest to localize: just use the /tellraw command! Simply replace any literal text with the translate tag, moving any "extra" arrays to the "with" array. To localize a /say command or /me command and preserve the default chat formatting (or to simulate chat with the /tellraw command), call the default chat translations and use your custom translations in the "with" array.
Note: Do not put quotations around the tags in the "with" array. Unlike signs and books, the "with" array is a chat component array.
This produces the following in chat:
Just add translations for these to produce a localized message from a localized sender. Here is a list of the default chat formats:
chat.type.text (<%s> %s): player chat
chat.type.announcement ([%s] %s): chat through the /say command
chat.type.emote (* %s %s): chat through the /me command
5. Summary
If you want to localize your map for multiple languages, the "translate" feature of text formatting is a powerful tool to quickly and easily create and edit translations without adding redstone to your map. Even if you do not plan to localize your map, having every line of text in a single file you can edit at any time will make it easier to edit your map's text. To take full advantage of this feature, link all text you want translated to lines in the language files. After you have added translations for the languages you wish to support, simply bundle the language pack with the map (as resources.zip) and localization will be applied automatically.
If you have any questions, suggestions, or further examples, please post them below. Good luck with your maps!
Hi kwerti, we've been playing with the translation tools to localise our latest map, There is no Learning Curve 2, but we're running into difficulties where entities are concerned. For example, we have a villager who is named a Window Shopper when you highlight them. Similarly, we have the elements of the periodic table named after different coloured wool blocks in one puzzle, but these elements have different names in different languages. We are unable to change the language file of the wool blocks due to other puzzles requiring wool blocks with their standard name. Do you know if there is any way to add a translate tag to an entity's name data?
Hi kwerti, we've been playing with the translation tools to localise our latest map, There is no Learning Curve 2, but we're running into difficulties where entities are concerned. For example, we have a villager who is named a Window Shopper when you highlight them. Similarly, we have the elements of the periodic table named after different coloured wool blocks in one puzzle, but these elements have different names in different languages. We are unable to change the language file of the wool blocks due to other puzzles requiring wool blocks with their standard name. Do you know if there is any way to add a translate tag to an entity's name data?
Thanks
Mental Block Gaming
Entity display names are one of the few things that cannot be localized because they do not yet use JSON text components. You will have to use manual localizing (different wool items / villagers for different languages; there is another thread in Maps Discussion, I believe, that explains how to localize with /scoreboard and command blocks) or just have the names in English.
Do you want to make your map available in multiple languages? This tutorial outlines how to provide automatic, expandable localizations to your map on anything that uses text formatting. This includes signs, chat, books, and titles. Basically, you will make a language pack that translates every single line of text in your map and bundle it with your map.
1. Text Formatting
Before you start translating, you will need to understand the basics of text formatting in Minecraft. Text formatting is controlled using the syntax of the /tellraw command. If you are already familiar with this command, you know that text can be made bold, italic, underlined, strikethrough, and colored, as well as added click- and hover-events. Text formatting also has a less-known feature: translate. As described in 1.8 - Raw JSON Text Examples:
The translate tag's value is a line in a language file, e.g. "tile.stone.name". This value is not limited to the default language translations, but can be anything, and the tag will accept and read custom lines from language files. As well as text formatting, the language files themselves allow for limited string formatting of variables. Language files accept:
Any formatter can also use "#$", the index of the "with" array used with the translate tag. You cannot specify additional number formatting such as alignment or precision, so it is best to always use %s. Use %s when you want to add player names, scores, and special click or hover events to your localized text. This allows maximal flexibility for your translation.
2. Test Case: Signs
By far signs are the classic method of communication in custom maps. Here is how to use text formatting on signs. First, place the sign where you want it to be (or not, you can always use the pick block +NBT feature). Then, instead of writing on it, use the /blockdata command to add the translate tag:
The sign now looks like this:
Note: Do not put quotes around Text1, Text2, Text3, or Text4.
You should put the default translation in the en_US.lang file. Set up a resource pack with a blank en_US.lang file (and nothing else!), and add the values of the translate tag to it. If you want the sign to say "Hello, I am speaking English!", you would write:
When you load the map with the resource pack, the same sign new says:If you want the sign to speak Spanish, place the same lines in the es_MX.lang file.
When you select Spanish (Mexican) as the language, the sign now says:
Of course, you will need to provide the translations.
3. Test Case: Books
You cannot write a localized book in the normal way. You must use the /give command to get a book with the title and author you want to be displayed. Book titles (and custom item names) are some of the few texts that cannot be formatted, so you will not be able to localize the book's title. Localizing the pages are done much like for signs; just use the translate tag. As an example:
Note: You must provide both a title and author for the book to be readable.
Simply write your translation in the language file and it will display in the book. Line breaks will be added automatically, but you will have to make sure that your translation does not overflow the page.
To forcibly insert line breaks, use "%1$s" where each line break will go and add "\n" to the first index of the "with" array.
4. Test Case: Chat
Chat is the easiest to localize: just use the /tellraw command! Simply replace any literal text with the translate tag, moving any "extra" arrays to the "with" array. To localize a /say command or /me command and preserve the default chat formatting (or to simulate chat with the /tellraw command), call the default chat translations and use your custom translations in the "with" array.
Instead of the /say command, use:
Note: Do not put quotations around the tags in the "with" array. Unlike signs and books, the "with" array is a chat component array.
This produces the following in chat:
Just add translations for these to produce a localized message from a localized sender. Here is a list of the default chat formats:
5. Summary
If you want to localize your map for multiple languages, the "translate" feature of text formatting is a powerful tool to quickly and easily create and edit translations without adding redstone to your map. Even if you do not plan to localize your map, having every line of text in a single file you can edit at any time will make it easier to edit your map's text. To take full advantage of this feature, link all text you want translated to lines in the language files. After you have added translations for the languages you wish to support, simply bundle the language pack with the map (as resources.zip) and localization will be applied automatically.
If you have any questions, suggestions, or further examples, please post them below. Good luck with your maps!
Putting the CENDENT back in transcendent!
This tutorial is fantastic! I was just looking for something like this. Great job!
Hi kwerti, we've been playing with the translation tools to localise our latest map, There is no Learning Curve 2, but we're running into difficulties where entities are concerned. For example, we have a villager who is named a Window Shopper when you highlight them. Similarly, we have the elements of the periodic table named after different coloured wool blocks in one puzzle, but these elements have different names in different languages. We are unable to change the language file of the wool blocks due to other puzzles requiring wool blocks with their standard name. Do you know if there is any way to add a translate tag to an entity's name data?
Thanks
Mental Block Gaming
Entity display names are one of the few things that cannot be localized because they do not yet use JSON text components. You will have to use manual localizing (different wool items / villagers for different languages; there is another thread in Maps Discussion, I believe, that explains how to localize with /scoreboard and command blocks) or just have the names in English.
Putting the CENDENT back in transcendent!