From 5c0eda76e879290fa1f78901d74f64d53b469633 Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Sun, 28 May 2023 13:48:22 +0200 Subject: [PATCH] Don't replace unchanged 1.12->1.13 translations with hard text Also add the remaining unchanged keys to the file Fixes #3284 --- .../data/MappingData.java | 53 ++++++++------- .../data/mapping-lang-1.12-1.13.json | 67 ++++++++++++++++++- 2 files changed, 93 insertions(+), 27 deletions(-) diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13to1_12_2/data/MappingData.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13to1_12_2/data/MappingData.java index 03729fd20..54b4e1425 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13to1_12_2/data/MappingData.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13to1_12_2/data/MappingData.java @@ -94,37 +94,38 @@ public class MappingData extends MappingDataBase { } } - Map translateData = GsonUtil.getGson().fromJson( + Map translationMappingData = GsonUtil.getGson().fromJson( new InputStreamReader(MappingData.class.getClassLoader().getResourceAsStream("assets/viaversion/data/mapping-lang-1.12-1.13.json")), new TypeToken>() { }.getType()); - try { - String[] lines; - try (Reader reader = new InputStreamReader(MappingData.class.getClassLoader() - .getResourceAsStream("assets/viaversion/data/en_US.properties"), StandardCharsets.UTF_8)) { - lines = CharStreams.toString(reader).split("\n"); - } - for (String line : lines) { - if (line.isEmpty()) { - continue; - } - String[] keyAndTranslation = line.split("=", 2); - if (keyAndTranslation.length != 2) { - continue; - } - - String key = keyAndTranslation[0]; - String translation = keyAndTranslation[1].replaceAll("%(\\d\\$)?d", "%$1s").trim(); - mojangTranslation.put(key, translation); - - String dataValue = translateData.get(key); - if (dataValue != null) { - translateMapping.put(key, dataValue); - } - } + String[] unmappedTranslationLines; + try (Reader reader = new InputStreamReader(MappingData.class.getClassLoader() + .getResourceAsStream("assets/viaversion/data/en_US.properties"), StandardCharsets.UTF_8)) { + unmappedTranslationLines = CharStreams.toString(reader).split("\n"); } catch (IOException e) { - e.printStackTrace(); + throw new RuntimeException(e); + } + + for (String line : unmappedTranslationLines) { + if (line.isEmpty()) { + continue; + } + + String[] keyAndTranslation = line.split("=", 2); + if (keyAndTranslation.length != 2) { + continue; + } + + String key = keyAndTranslation[0]; + String translation = keyAndTranslation[1].replaceAll("%(\\d\\$)?d", "%$1s").trim(); + mojangTranslation.put(key, translation); + + // Null values in the file mean the key did not change AND the translation has the same amount of placeholders still + if (translationMappingData.containsKey(key)) { + String mappedKey = translationMappingData.get(key); + translateMapping.put(key, mappedKey != null ? mappedKey : key); + } } } diff --git a/common/src/main/resources/assets/viaversion/data/mapping-lang-1.12-1.13.json b/common/src/main/resources/assets/viaversion/data/mapping-lang-1.12-1.13.json index bc62a15cb..d034c617b 100644 --- a/common/src/main/resources/assets/viaversion/data/mapping-lang-1.12-1.13.json +++ b/common/src/main/resources/assets/viaversion/data/mapping-lang-1.12-1.13.json @@ -2752,5 +2752,70 @@ "advancements.story.smelt_iron.title": null, "advancements.story.smelt_iron.description": null, "advancements.story.upgrade_tools.title": null, - "advancements.story.upgrade_tools.description": null + "selectWorld.edit.openFolder": null, + "selectWorld.edit.save": null, + "selectWorld.versionWarning": null, + "selectWorld.versionJoinButton": null, + "selectWorld.allowCommands.info": null, + "multiplayer.downloadingTerrain": null, + "multiplayer.disconnect.banned": null, + "multiplayer.disconnect.ip_banned": null, + "multiplayer.disconnect.kicked": null, + "disconnect.loginFailed": null, + "disconnect.loginFailedInfo": null, + "options.narrator.off": null, + "key.mouse.left": null, + "key.mouse.middle": null, + "key.mouse.right": null, + "structure_block.size_failure": null, + "death.attack.hotFloor": null, + "commands.setidletimeout.success": null, + "commands.summon.failed": null, + "commands.setblock.failed": null, + "commands.fill.success": null, + "commands.fill.failed": null, + "commands.clone.success": null, + "commands.clone.failed": null, + "commands.time.query": null, + "commands.op.success": null, + "commands.deop.success": null, + "commands.banip.invalid": null, + "commands.save.enabled": null, + "commands.save.disabled": null, + "commands.save.success": null, + "commands.advancement.criterionNotFound": null, + "commands.reload.success": null, + "commands.scoreboard.objectives.add.success": null, + "commands.scoreboard.objectives.remove.success": null, + "commands.scoreboard.objectives.list.empty": null, + "commands.scoreboard.players.list.empty": null, + "commands.defaultgamemode.success": null, + "commands.difficulty.success": null, + "commands.setworldspawn.success": null, + "commands.worldborder.center.success": null, + "commands.locate.success": null, + "subtitles.entity.generic.small_fall": null, + "subtitles.entity.llama.angry": null, + "subtitles.item.armor.equip": null, + "subtitles.item.armor.equip_elytra": null, + "debug.reload_chunks.help": null, + "debug.show_hitboxes.help": null, + "debug.clear_chat.help": null, + "debug.cycle_renderdistance.help": null, + "debug.chunk_boundaries.help": null, + "debug.advanced_tooltips.help": null, + "debug.creative_spectator.help": null, + "debug.pause_focus.help": null, + "debug.help.help": null, + "debug.reload_resourcepacks.help": null, + "advancements.adventure.sleep_in_bed.title": null, + "advancements.adventure.sniper_duel.title": null, + "advancements.adventure.sniper_duel.description": null, + "advancements.end.elytra.description": null, + "advancements.end.respawn_dragon.description": null, + "advancements.nether.get_wither_skull.description": null, + "advancements.nether.fast_travel.description": null, + "advancements.nether.uneasy_alliance.description": null, + "advancements.story.cure_zombie_villager.description": null, + "advancements.story.follow_ender_eye.description": null }