Uploaded image for project: 'Minecraft: Java Edition'
  1. Minecraft: Java Edition
  2. MC-218631

Cannot specify format with max-decimals in translation strings

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Invalid
    • None
    • 1.16.5
    • None
    • Unconfirmed
    • (Unassigned)

      String.format in java allows you to specify the number of decimals to show in a formatting string by putting a dot and the number of decimals after the "%" sign.

       

      i.e. "%.2f" with the value 3.1416926543560 should yield the result "3.14".

      If you do the same using a translation string in a custom language, you get the result: "3.1416926543560".

       

      It doesn't seem like a particularly significant bug, since the game only uses %s and %d itself, but since it already supports placement holders ("%1$s %2$s") it would just make everyone's lives easier to include this as well.

       

      Related: Even though Mojang is using numerical placeholders in their language files...

      "narration.suggestion": "Selected suggestion %d out of %d: %s",
      

      When translations are loaded, they are explicitly stripping them out:

      String string = TOKEN_PATTERN.matcher(JsonHelper.asString(entry.getValue(), entry.getKey())).replaceAll("%$1s");

       

      ... which is very... uh...

            Unassigned Unassigned
            awr_* Sollace
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: