From 4bb571e4308bd4886fc1d68dd6eeefc91474f622 Mon Sep 17 00:00:00 2001 From: AnthonyFuller <24512050+AnthonyFuller@users.noreply.github.com> Date: Sat, 11 Nov 2023 13:30:23 +0000 Subject: [PATCH] [GUI] Refactor finding of translations in get_line_string --- src/get_line_string.cpp | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/src/get_line_string.cpp b/src/get_line_string.cpp index 60e72e2..87e5154 100644 --- a/src/get_line_string.cpp +++ b/src/get_line_string.cpp @@ -126,26 +126,18 @@ void rpkg_function::get_line_string(std::string& input_path, std::string& filter true, "HM3"); for (const auto& [language, translations] : localization_json["languages"].items()) { - std::string found_translation = ""; - std::string plainLine = ""; + std::string locrKey = TonyTools::Language::HashList::GetLine(line_crc32); std::string hash = util::uint32_t_to_hex_string(line_crc32); - for (const auto& [line, str] : translations.items()) { - if (TonyTools::Language::HashList::GetLineHash(line) == hash) { - found_translation = str.get(); - - // If line != hash, then we have an actual hash for it, display it. - if (line != hash) { - plainLine = "LINE: " + line + "\n"; - } - - break; - } + if (!translations.contains(locrKey)) { + continue; } + std::string found_translation = translations.at(locrKey).get(); + if (found_translation != "") { if (localization_line_string == "") { - localization_line_string = "\n" + plainLine + "LINE hash: " + hash + "\nLOCR Strings:\n"; + localization_line_string = "\n" + (hash != locrKey ? "LINE: " + locrKey + "\n" : "") + "Hash: " + hash + "\nLOCR Strings:\n"; } localization_line_string += " - " + language + ": " + found_translation + "\n";