impr: Add localization option to store long, formatted texts in external files

This commit is contained in:
WerWolv 2025-12-15 20:07:18 +01:00
parent c161a5c71b
commit 021c7e5fdb
1 changed files with 12 additions and 0 deletions

View File

@ -104,9 +104,21 @@ namespace hex {
for (const auto &entry : json.items()) { for (const auto &entry : json.items()) {
auto value = entry.value().get<std::string>(); auto value = entry.value().get<std::string>();
// Skip empty values
if (value.empty()) if (value.empty())
continue; 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)); localizations.try_emplace(LangConst::hash(entry.key()), std::move(value));
} }
} catch (std::exception &e) { } catch (std::exception &e) {