From 021c7e5fdb3e96f727ca09391ea601f4fcef7388 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Mon, 15 Dec 2025 20:07:18 +0100 Subject: [PATCH] impr: Add localization option to store long, formatted texts in external files --- lib/libimhex/source/api/localization_manager.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/libimhex/source/api/localization_manager.cpp b/lib/libimhex/source/api/localization_manager.cpp index bc93f3a7e..a1e391d09 100644 --- a/lib/libimhex/source/api/localization_manager.cpp +++ b/lib/libimhex/source/api/localization_manager.cpp @@ -104,9 +104,21 @@ namespace hex { for (const auto &entry : json.items()) { auto value = entry.value().get(); + + // Skip empty values if (value.empty()) continue; + // Handle references to files + if (value.starts_with("#@")) { + try { + value = path.callback(value.substr(2)); + } catch (std::exception &e) { + log::error("Failed to load localization file reference '{}': {}", entry.key(), e.what()); + continue; + } + } + localizations.try_emplace(LangConst::hash(entry.key()), std::move(value)); } } catch (std::exception &e) {