mojira.dev
MC-260650

JSON text component / chat component error messages are not translatable

The bug

When inputting a command with mistakes in the JSON text argument, the error in chat appears in English, no matter the language. Translators on Crowdin can't fix that, as the strings are not present in the Minecraft Translation project on the website.

Steps to reproduce

  • Start Minecraft in an affected version.

  • Go to Settings - Language, and select a language other than English.

  • Create a new single-player world with the cheats option turned on.

  • Open up chat or place a command block and type in a /tellraw or a /title command using a JSON text component with errors as the text argument, for example:

    • /title @a title {"wrong":"JSON"}

    • /tellraw @a {"translate":"chat.type.advancement.task","with":"Wrong JSON"}

  • Press Enter in chat or activate the command block.

  • See the error message in chat or in the command block.

  • Go to https://crowdin.com/translate/minecraft/all/ and search for part of the text found in the error message

Observed behaviour

The error message starts with a translation of "Invalid Chat component", but continues in English. The untranslated part is absent from the Minecraft Translation project on Crowdin.

Expected behaviour

The error messages should be present in the Minecraft Translation project on Crowdin, and for the languages where that translation is provided, the errors message should be output in that language.

List of untranslatable error messages

  • <-- [HERE] (in some contexts, even if command.context.here is translated)

/data get entity @a[limit=1] 1 {}
  • A score component needs at least a name and an objective

  • a boolean (%s) (found in the Source Code, as a returned value)

  • a number (%s) (found in the Source Code, as a returned value)

  • an array (%) (found in the Source Code, as a returned value)

  • an object (%s) (found in the Source Code, as a returned value)

  • Couldn't get field 'lineStart' for JsonReader

  • Couldn't get field 'pos' for JsonReader

  • Couldn't read position of JsonReader

  • Couldn't write %s (found in the Source Code, as an IllegalArgumentException)

  • Don't know how to serialize %s as a Component

  • Don't know how to turn %s into a Component

/title @a title {"wrong":"JSON"}
  • Empty at position %s: %s

/tellraw @s []
  • Expected ':' at line %s column %s path %s

/tellraw @s [{"hoverEvent"}]
  • Expected %s to be ..., was %s (found in the Source Code, as a JsonSyntaxException)

    • a string

    • an item

    • a Boolean

    • a Double

    • a Float

    • a Long

    • a Int

    • a Byte

    • a Character

    • a BigDecimal

    • a BigInteger

    • a Short

    • a JsonObject

    • a JsonArray

/tellraw @a {"translate":"chat.type.advancement.task","with":"Wrong JSON"}
  • Expected %s to be ..., was unknown string '%s' (found in the Source Code, as a JsonSyntaxException)

  • Item cannot be both damageable and stackable

/give @s apple[max_damage=999999999,max_stack_size=10]
  • JSON data was null or empty (found in the Source Code, as a JsonParseException)

  • Missing %s (found in the Source Code, as a JsonSyntaxException)

  • Missing field %s (found in the Source Code, as a JsonSyntaxException)

  • Missing %s, expected to find ... (found in the Source Code, as a JsonSyntaxException)

    • a string

    • an item

    • a Boolean

    • a Double

    • a Float

    • a Long

    • a Int

    • a Byte

    • a Character

    • a BigDecimal

    • a BigInteger

    • a Short

    • a JsonObject

    • a JsonArray

  • No key %s in MapLike[%s]

/particle minecraft:dust
  • Not a boolean (found in the Source Code, as a returned value)

  • Not a byte list (found in the Source Code, as a returned value)

  • Not a JSON object: %s; Not a json array: %s; Not a string: %s (might be related to the β€œNot a string” string below)

/give @s apple[minecraft:custom_name="1"]
  • Not a list (found in the Source Code, as a returned value)

  • Not a long list (found in the Source Code, as a returned value)

  • Not a map (found in the Source Code, as a returned value)

  • Not a number (found in the Source Code, as a returned value)

  • Not a string (found in the Source Code, as a returned value)

  • Not an int list (found in the Source Code, as a returned value)

  • Null (found in the Source Code, as a returned value)

  • null (json) (found in the Source Code, as a returned value)

  • null (missing) (found in the Source Code, as a returned value)

  • Unexpected empty array of components

  • Use JsonReader.setLenient(true) to accept malformed JSON at line %s column %s path %s

/tellraw @s [{"nbt":"textures.CAPE.url","storage":"base64:decode","clickEvent": {"action":"open_url","value":'\{"nbt":"textures.CAPE.url","storage":"base64:decode"}'}}]

List of translatable error messages

Β The following messages were affected but are now translatable

  • Can't parse particle options: %s

particle.invalidOptions

Notes

There are probably other types of errors with JSON text components that I'm not aware of. There is a high chance of them not being translatable either. If you find other error messages that are not translatable, please show them in the comments

UPD: @bodakugga has found 7 error messages that seem to be not translatable

UPD2: @Cybereggs1337 has found 2 more error messages that can be seen in component-error-messages.png

UPD3: @Nethonos has found another error message that can be seen in particle-error-message.png

UPD4: @Cybereggs1337 has found a lot of other untranslatable or potentially untranslatable messages

Links

Search filter for Don't know as in Don't know how to turn {"wrong":"JSON"} into a Component, with 0 results, demonstrating that the error message is not translatable
Case-sensitive search filter for Expected as in Expected with to be a JsonArray, was "Wro...ON", with 21 result neither of which corresponds to the error message, demonstrating that the error message is not translatable

Attachments

Comments 11

I can confirm this behavior.

Found in net\minecraft\network\chat\Component.java

  • "A score component needs a least a name and an objective"

  • "Don't know how to turn " + jsonElement + " into a Component"

  • "Unexpected empty array of components"

  • "Don't know how to serialize " + componentContents + " as a Component"

Also these, but I don't know if they are sent to chat:

  • "Couldn't get field 'pos' for JsonReader"

  • "Couldn't get field 'lineStart' for JsonReader"

  • "Couldn't read position of JsonReader"

[media]

Can confirm this on all Versions with Component System.

I assume that there's can be more hardcoded Translations, but there's two Commands to produce two hardcoded Error Messages.

/give @s apple[max_damage=999999999,max_stack_size=10]
/give @s apple[minecraft:custom_name="1"]

Update: the Particle String was found as

particle.invalidOptions

Outdated Version of this Comment:
Credits to @unknown.

I want to share this Error Message with y'all!
How to reproduce:
Try to use this Command:

/particle minecraft:dust{}

Still not fixed in 20w18a, 20w19ab, 20w20a and many other Versions...

1 more comments

It is possible that this Problem can be reported as other Bug, but there's untranslatable "<--[HERE]", even if command.context.here is translated.

[media]

/tellraw @s []
[media]

/tellraw @s [{"hoverEvent"}]
[media]

/tellraw @s [{"translate":"%s","with":"s"}]
[media]

/tellraw @s [{"translate":"%s","with":{"%s":"1"}}]
[media]

/tellraw @s [{"translate":"%d","with":[%d]}]
[media]

Hello!

I decided to research Source Code to find those Strings... and I found it!

In

net\minecraft\util\GsonHelper.java

These Strings were found (1.21-pre1):

throw new JsonSyntaxException("Missing field " + var1);
throw new JsonSyntaxException("Expected " + var1 + " to be a string, was " + getType(var0));
throw new JsonSyntaxException("Missing " + var1 + ", expected to find a string");
return new JsonSyntaxException("Expected " + var1 + " to be an item, was unknown string '" + var2 + "'");
throw new JsonSyntaxException("Expected " + var1 + " to be an item, was " + getType(var0));
throw new JsonSyntaxException("Missing " + var1 + ", expected to find an item");
throw new JsonSyntaxException("Expected " + var1 + " to be a Boolean, was " + getType(var0));
throw new JsonSyntaxException("Missing " + var1 + ", expected to find a Boolean");
throw new JsonSyntaxException("Expected " + var1 + " to be a Double, was " + getType(var0));
throw new JsonSyntaxException("Missing " + var1 + ", expected to find a Double");
throw new JsonSyntaxException("Expected " + var1 + " to be a Float, was " + getType(var0));
throw new JsonSyntaxException("Missing " + var1 + ", expected to find a Float");
throw new JsonSyntaxException("Expected " + var1 + " to be a Long, was " + getType(var0));
throw new JsonSyntaxException("Missing " + var1 + ", expected to find a Long");
throw new JsonSyntaxException("Expected " + var1 + " to be a Int, was " + getType(var0));
throw new JsonSyntaxException("Missing " + var1 + ", expected to find a Int");
throw new JsonSyntaxException("Expected " + var1 + " to be a Byte, was " + getType(var0));
throw new JsonSyntaxException("Missing " + var1 + ", expected to find a Byte");
throw new JsonSyntaxException("Expected " + var1 + " to be a Character, was " + getType(var0));
throw new JsonSyntaxException("Missing " + var1 + ", expected to find a Character");
throw new JsonSyntaxException("Expected " + var1 + " to be a BigDecimal, was " + getType(var0));
throw new JsonSyntaxException("Missing " + var1 + ", expected to find a BigDecimal");
throw new JsonSyntaxException("Expected " + var1 + " to be a BigInteger, was " + getType(var0));
throw new JsonSyntaxException("Missing " + var1 + ", expected to find a BigInteger");
throw new JsonSyntaxException("Expected " + var1 + " to be a Short, was " + getType(var0));
throw new JsonSyntaxException("Missing " + var1 + ", expected to find a Short");
throw new JsonSyntaxException("Expected " + var1 + " to be a JsonObject, was " + getType(var0));
throw new JsonSyntaxException("Missing " + var1 + ", expected to find a JsonObject");
throw new JsonSyntaxException("Expected " + var1 + " to be a JsonArray, was " + getType(var0));
throw new JsonSyntaxException("Missing " + var1 + ", expected to find a JsonArray");
throw new JsonSyntaxException("Missing " + var1);
return "null (missing)";
         return "null (json)";
         return "an array (" + var1 + ")";
         return "an object (" + var1 + ")";
               return "a number (" + var1 + ")";
               return "a boolean (" + var1 + ")";
throw new JsonParseException("JSON data was null or empty");
throw new IllegalArgumentException("Couldn't write " + String.valueOf(var1.getClass()));

In same Directory, but in

NullOps.java

were found these Strings:

return "Not a number";
         return "Not a boolean";
         return "Not a string";
         return "Not a map";
         return "Not a list";
         return "Not a byte list";
         return "Not an int list";
         return "Not a long list";
      return "Null";

Possibly in the same Directory affected

ProblemReporter.java
return " at " + var10000 + ": " + String.join("; ", (Iterable)var0.getValue());

I also found

net\minecraft\nbt\NbtOps.java

This file also contains similar with

NullOps.java

But it also contains "MapLike[{}]" and others.

Also it affected 1.18.2 and probably the Versions that much older that 1.18.2 and up to 1.19.4 Pre-release 2.

[media]

Thank you for your report!
After consideration, the issue is being closed as Won't Fix.

Please note that this is not the same as Working as Intended, as this bug report correctly describes behavior in the game that might not be the intended or desirable behavior, but it will not be fixed right now. Sometimes, this is because the issue reported is minor and/or impossible to change without large architectural changes to the code base.

Quick Links:
πŸ““ Bug Tracker Guidelines – πŸ’¬ Community Support – πŸ“§ Mojang Support (Technical Issues) – πŸ“§ Microsoft Support (Account Issues)
πŸ““ Project Summary – ✍️ Feedback and Suggestions – πŸ“– Game Wiki

Ajno

(Unassigned)

Confirmed

Platform

Important

Internationalisation

component, error-message, json, translatability, translation

1.19.4 Pre-release 2, 1.20.5, 1.20.6 Release Candidate 1, 1.20.6, 24w20a, 24w21b, 1.21 Pre-Release 1, 1.21 Pre-Release 2, 1.21 Pre-Release 4, 24w40a

Retrieved