Skip to content

Localized Written Book

KameiB edited this page Jan 4, 2025 · 3 revisions

Localized Written Book

First, let's look at a normal Written Book (you might want to check the Wiki):

{
	pages:
	["
		{
			"text" : "Do not run but hide as they will come."
		}
	"],
	title: "At Twilight",
	author: "The Dark Witch"
}

Just remember, a Written book must have a Title (locTitle / title) tag to be valid!
Also, the title value must not exceed 32 characters!

Now let's get into it!

pages: Minecraft natively supports raw json format for the page contents.
This means you can use "translate" instead of "text" and a lang key for each page!

title: Localizator adds the locTitle NBT tag, which supports lang keys. It takes the lang key value (not its name) into the 32 characters limit.

author: Localizator adds the locAuthor NBT tag, which support lang keys.

This is how a FULLY localized Written Book looks like:

{
	pages:
	["
		{
			"translate": "book.lang.key.page.1"
		}
	"],
	locTitle: "book.lang.key.title",
	locAuthor: "book.lang.key.author"
}

Usage

Test it now with the following command (you might need a Command Block!)

/give @p written_book 1 0 {pages:["{\"translate\":\"book.localizator.Example.page.1\"}"],locTitle:"book.localizator.Example.title",locAuthor:"book.localizator.Example.author"}

image

image

Support for Vanilla clients

What? You want to add lore AND also support vanilla clients? Well, here it comes!

{
	pages:
	["
		{
			"translate": "book.localizator.Example.page.1"
		}
	"],
	locTitle: "book.localizator.Example.title",
	title: "This is a book",
	locAuthor: "book.localizator.Example.author",
	author: "KameiB",
	display:
	{
		LocLore: ["book.localizator.Example.lore"],
		Lore:["Awesome lore"]
	}
}

Usage

Test it with the following command (you WILL need a Command block!):

/give @p written_book 1 0 {pages:["{\"translate\":\"book.localizator.Example.page.1\"}"],locTitle:"book.localizator.Example.title",title:"This is a book",locAuthor:"book.localizator.Example.author",author:"KameiB",display:{LocLore:["book.localizator.Example.lore"],Lore:["Awesome lore"]}}

image

Vanilla will ignore my tags, and Localizator will show my tags instead of the Vanilla ones. Beautiful!

And yes, these tags are interchangeable! which means you can also do this:

{
	pages:
	["
		{
			"translate": "book.localizator.Example.page.1"
		}
	"],
	locTitle: "book.localizator.Example.title",
	author: "KameiB",
	display:
	{
		Lore: ["Awesome lore"]
	}
} 

Usage

Test it with the following command (you WILL need a Command block!):

   /give @p written_book 1 0 {pages:["{\"translate\":\"book.localizator.Example.page.1\"}"],locTitle:"book.localizator.Example.title",author:"KameiB",display:{Lore:["Awesome lore"]}}

image

Localized Writable Book

This one only needs the pages NBT list tag, so you only need to add the new locPages NBT list tag with its respective lang keys, and you're good to go!

image

Clone this wiki locally