mirror of https://github.com/WerWolv/ImHex
impr: Add localization option to store long, formatted texts in external files
This commit is contained in:
parent
c161a5c71b
commit
021c7e5fdb
|
|
@ -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) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue