3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-10-01 23:50:11 +02:00

Fix: using curly brackets in custom Minecraft locale overrides

Dieser Commit ist enthalten in:
chris 2024-05-17 22:48:46 +02:00 committet von GitHub
Ursprung b010c500d8
Commit 5ebb6ef0d6
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: B5690EEEBB952194

Datei anzeigen

@ -63,6 +63,13 @@ public class MinecraftTranslationRegistry extends TranslatableComponentRenderer<
} }
} }
// replace single quote instances which get lost in MessageFormat otherwise
localeString = localeString.replace("'", "''");
// Wrap all curly brackets with single quote inserts - fixes https://github.com/GeyserMC/Geyser/issues/4662
localeString = localeString.replace("{", "'{")
.replace("}", "'}");
// Replace the `%s` with numbered inserts `{0}` // Replace the `%s` with numbered inserts `{0}`
Pattern p = stringReplacement; Pattern p = stringReplacement;
Matcher m = p.matcher(localeString); Matcher m = p.matcher(localeString);
@ -83,8 +90,7 @@ public class MinecraftTranslationRegistry extends TranslatableComponentRenderer<
} }
m.appendTail(sb); m.appendTail(sb);
// replace single quote instances which get lost in MessageFormat otherwise
// Locale shouldn't need to be specific - dates for example will not be handled // Locale shouldn't need to be specific - dates for example will not be handled
return new MessageFormat(sb.toString().replace("'", "''"), Locale.ROOT); return new MessageFormat(sb.toString(), Locale.ROOT);
} }
} }