From e450a2b4593e6b25d9cb43bd3522a3cce1b81ab6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dami=C3=A1n=20Garro?= Date: Fri, 9 Sep 2022 18:48:31 -0300 Subject: [PATCH] Fix dialog text not trimmed in translation table key --- NewHorizons/Builder/Props/DialogueBuilder.cs | 6 ++++-- NewHorizons/Handlers/TranslationHandler.cs | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/NewHorizons/Builder/Props/DialogueBuilder.cs b/NewHorizons/Builder/Props/DialogueBuilder.cs index f917c973..7d1beb0c 100644 --- a/NewHorizons/Builder/Props/DialogueBuilder.cs +++ b/NewHorizons/Builder/Props/DialogueBuilder.cs @@ -211,7 +211,8 @@ namespace NewHorizons.Builder.Props { XmlNode pageData = (XmlNode)Page; var text = pageData.InnerText; - TranslationHandler.AddDialogue(text, name); + // The text is trimmed in CharacterDialogueTree.LoadXml, so we also need to trim it for the key + TranslationHandler.AddDialogue(text, true, name); } xmlText = xmlNode2.SelectNodes("DialogueOptionsList/DialogueOption/Text"); @@ -219,7 +220,8 @@ namespace NewHorizons.Builder.Props { XmlNode pageData = (XmlNode)Page; var text = pageData.InnerText; - TranslationHandler.AddDialogue(text, characterName, name); + // The text is trimmed in DialogueText constructor (_listTextBlocks), so we also need to trim it for the key + TranslationHandler.AddDialogue(text, true, characterName, name); } } } diff --git a/NewHorizons/Handlers/TranslationHandler.cs b/NewHorizons/Handlers/TranslationHandler.cs index 03910e2b..38c6e76e 100644 --- a/NewHorizons/Handlers/TranslationHandler.cs +++ b/NewHorizons/Handlers/TranslationHandler.cs @@ -100,9 +100,9 @@ namespace NewHorizons.Handlers } } - public static void AddDialogue(string rawText, params string[] rawPreText) + public static void AddDialogue(string rawText, bool trimRawTextForKey = false, params string[] rawPreText) { - var key = string.Join(string.Empty, rawPreText) + rawText; + var key = string.Join(string.Empty, rawPreText) + (trimRawTextForKey? rawText.Trim() : rawText); var text = GetTranslation(rawText, TextType.DIALOGUE);