impr: Fix various issues with runtime-generated language strings

This commit is contained in:
WerWolv
2024-08-03 11:32:17 +02:00
parent efee128c1c
commit b2fc80f970
12 changed files with 108 additions and 73 deletions

View File

@@ -111,8 +111,8 @@ namespace hex::plugin::builtin {
s_autoBackupTime = value.get<int>(0) * 30;
});
ContentRegistry::BackgroundServices::registerService("hex.builtin.background_service.network_interface"_lang, handleNetworkInterfaceService);
ContentRegistry::BackgroundServices::registerService("hex.builtin.background_service.auto_backup"_lang, handleAutoBackup);
ContentRegistry::BackgroundServices::registerService("hex.builtin.background_service.network_interface", handleNetworkInterfaceService);
ContentRegistry::BackgroundServices::registerService("hex.builtin.background_service.auto_backup", handleAutoBackup);
EventProviderDirtied::subscribe([](prv::Provider *) {
s_dataDirty = true;

View File

@@ -174,7 +174,7 @@ namespace hex::plugin::builtin {
bool draw(const std::string &name) override {
auto format = [this] -> std::string {
if (m_value == 0)
return "hex.builtin.setting.interface.scaling.native"_lang + hex::format(" (x{:.1f})", ImHexApi::System::getNativeScale());
return hex::format("{} (x{:.1f})", "hex.builtin.setting.interface.scaling.native"_lang, ImHexApi::System::getNativeScale());
else
return "x%.1f";
}();

View File

@@ -42,7 +42,7 @@ namespace hex::plugin::builtin {
// Task exception toast
for (const auto &task : TaskManager::getRunningTasks()) {
if (task->hadException()) {
ui::ToastError::open(hex::format("hex.builtin.popup.error.task_exception"_lang, task->getName(), task->getExceptionMessage()));
ui::ToastError::open(hex::format("hex.builtin.popup.error.task_exception"_lang, Lang(task->getUnlocalizedName()), task->getExceptionMessage()));
task->clearException();
break;
}
@@ -268,7 +268,7 @@ namespace hex::plugin::builtin {
else
progressString = hex::format("[ {}/{} ({:.1f}%) ] ", frontTask->getValue(), frontTask->getMaxValue(), std::min(progress, 1.0F) * 100.0F);
ImGuiExt::InfoTooltip(hex::format("{}{}", progressString, frontTask->getName()).c_str());
ImGuiExt::InfoTooltip(hex::format("{}{}", progressString, Lang(frontTask->getUnlocalizedName())).c_str());
if (ImGui::BeginPopupContextItem("RestTasks", ImGuiPopupFlags_MouseButtonLeft)) {
for (const auto &task : tasks) {
@@ -276,7 +276,7 @@ namespace hex::plugin::builtin {
continue;
ImGui::PushID(&task);
ImGuiExt::TextFormatted("{}", task->getName());
ImGuiExt::TextFormatted("{}", Lang(task->getUnlocalizedName()));
ImGui::SameLine();
ImGui::SeparatorEx(ImGuiSeparatorFlags_Vertical);
ImGui::SameLine();

View File

@@ -166,7 +166,7 @@ namespace hex::plugin::builtin {
if (auto [match, value] = MatchCommand(input, command); match != MatchType::NoMatch) {
if (match != MatchType::PerfectMatch) {
results.push_back({ command + " (" + Lang(unlocalizedDescription) + ")", "", AutoComplete });
results.push_back({ hex::format("{} ({})", command, Lang(unlocalizedDescription)), "", AutoComplete });
} else {
auto matchedCommand = wolv::util::trim(input.substr(command.length()));
results.push_back({ displayCallback(matchedCommand), matchedCommand, executeCallback });
@@ -178,7 +178,7 @@ namespace hex::plugin::builtin {
if (auto [match, value] = MatchCommand(input, command + " "); match != MatchType::NoMatch) {
if (match != MatchType::PerfectMatch) {
results.push_back({ command + " (" + Lang(unlocalizedDescription) + ")", "", AutoComplete });
results.push_back({ hex::format("{} ({})", command, Lang(unlocalizedDescription)), "", AutoComplete });
} else {
auto matchedCommand = wolv::util::trim(input.substr(command.length() + 1));
results.push_back({ displayCallback(matchedCommand), matchedCommand, executeCallback });