From 1a7bd49361a9de80466ab60b1a897e0e99ce6ecf Mon Sep 17 00:00:00 2001 From: WerWolv Date: Sat, 27 Jul 2024 16:29:06 +0200 Subject: [PATCH] impr: Make all task names properly translatable --- lib/libimhex/include/hex/ui/widgets.hpp | 2 +- lib/libimhex/source/api/imhex_api.cpp | 2 +- .../content/popups/popup_docs_question.hpp | 2 +- plugins/builtin/romfs/lang/en_US.json | 15 +++++++++++++++ plugins/builtin/source/content/init_tasks.cpp | 4 ++-- .../builtin/source/content/main_menu_items.cpp | 2 +- plugins/builtin/source/content/recent.cpp | 2 +- .../source/content/views/view_data_inspector.cpp | 2 +- .../source/content/views/view_data_processor.cpp | 2 +- .../builtin/source/content/views/view_find.cpp | 2 +- .../source/content/views/view_hex_editor.cpp | 2 +- .../source/content/views/view_pattern_editor.cpp | 6 +++--- .../builtin/source/content/views/view_store.cpp | 2 +- plugins/builtin/source/content/welcome_screen.cpp | 4 ++-- plugins/diffing/romfs/lang/en_US.json | 3 ++- .../diffing/source/content/views/view_diff.cpp | 2 +- plugins/script_loader/romfs/lang/en_US.json | 4 +++- .../script_loader/source/plugin_script_loader.cpp | 6 +++--- plugins/visualizers/romfs/lang/en_US.json | 3 ++- .../source/content/pl_visualizers/sound.cpp | 2 +- plugins/windows/romfs/lang/en_US.json | 3 ++- plugins/windows/source/views/view_tty_console.cpp | 2 +- 22 files changed, 47 insertions(+), 27 deletions(-) diff --git a/lib/libimhex/include/hex/ui/widgets.hpp b/lib/libimhex/include/hex/ui/widgets.hpp index 5b8043f05..8e4bcf9b2 100644 --- a/lib/libimhex/include/hex/ui/widgets.hpp +++ b/lib/libimhex/include/hex/ui/widgets.hpp @@ -35,7 +35,7 @@ namespace hex::ui { m_filteredEntries.clear(); m_filteredEntries.reserve(entries.size()); - m_updateTask = TaskManager::createBackgroundTask("Searching"_lang, [this, &entries, searchBuffer = m_searchBuffer](Task&) { + m_updateTask = TaskManager::createBackgroundTask(Lang("Searching"), [this, &entries, searchBuffer = m_searchBuffer](Task&) { for (auto &entry : entries) { if (searchBuffer.empty() || m_comparator(searchBuffer, entry)) m_filteredEntries.push_back(&entry); diff --git a/lib/libimhex/source/api/imhex_api.cpp b/lib/libimhex/source/api/imhex_api.cpp index 563cb8aed..89d018429 100644 --- a/lib/libimhex/source/api/imhex_api.cpp +++ b/lib/libimhex/source/api/imhex_api.cpp @@ -450,7 +450,7 @@ namespace hex { // Do the destruction of the provider in the background once all tasks have finished TaskManager::runWhenTasksFinished([providerToRemove] { EventProviderDeleted::post(providerToRemove); - TaskManager::createBackgroundTask("Closing Provider"_lang, [providerToRemove](Task &) { + TaskManager::createBackgroundTask(Lang("Closing Provider"), [providerToRemove](Task &) { eraseMutex.lock(); auto provider = std::move((*s_providersToRemove)[providerToRemove]); s_providersToRemove->erase(providerToRemove); diff --git a/plugins/builtin/include/content/popups/popup_docs_question.hpp b/plugins/builtin/include/content/popups/popup_docs_question.hpp index e2c7f6c3a..c71fb2f9e 100644 --- a/plugins/builtin/include/content/popups/popup_docs_question.hpp +++ b/plugins/builtin/include/content/popups/popup_docs_question.hpp @@ -85,7 +85,7 @@ namespace hex::plugin::builtin { private: void executeQuery() { - m_requestTask = TaskManager::createBackgroundTask("Query Docs"_lang, [this, input = m_inputBuffer](Task &) { + m_requestTask = TaskManager::createBackgroundTask("hex.builtin.task.query_docs"_lang, [this, input = m_inputBuffer](Task &) { m_noAnswer = false; for (auto space : { "xj7sbzGbHH260vbpZOu1", "WZzDdGjxmgMSIE3xly6o" }) { m_answer.clear(); diff --git a/plugins/builtin/romfs/lang/en_US.json b/plugins/builtin/romfs/lang/en_US.json index 70583a00d..e999335f2 100644 --- a/plugins/builtin/romfs/lang/en_US.json +++ b/plugins/builtin/romfs/lang/en_US.json @@ -521,6 +521,21 @@ "hex.builtin.setting.toolbar.icons": "Toolbar Icons", "hex.builtin.shortcut.next_provider": "Select next provider", "hex.builtin.shortcut.prev_provider": "Select previous provider", + "hex.builtin.task.query_docs": "Querying Docs...", + "hex.builtin.task.sending_statistics": "Sending statistics...", + "hex.builtin.task.check_updates": "Checking for updates...", + "hex.builtin.task.exporting_data": "Exporting data...", + "hex.builtin.task.uploading_crash": "Uploading crash report...", + "hex.builtin.task.loading_banner": "Loading banner...", + "hex.builtin.task.updating_recents": "Updating recent files...", + "hex.builtin.task.updating_store": "Updating store...", + "hex.builtin.task.parsing_pattern": "Parsing pattern...", + "hex.builtin.task.analyzing_data": "Analyzing data...", + "hex.builtin.task.updating_inspector": "Updating inspector...", + "hex.builtin.task.saving_data": "Saving data...", + "hex.builtin.task.loading_encoding_file": "Loading encoding file...", + "hex.builtin.task.filtering_data": "Filtering data...", + "hex.builtin.task.evaluating_nodes": "Evaluating nodes...", "hex.builtin.title_bar_button.debug_build": "Debug build\n\nSHIFT + Click to open Debug Menu", "hex.builtin.title_bar_button.feedback": "Leave Feedback", "hex.builtin.tools.ascii_table": "ASCII table", diff --git a/plugins/builtin/source/content/init_tasks.cpp b/plugins/builtin/source/content/init_tasks.cpp index e7fb02884..40b621603 100644 --- a/plugins/builtin/source/content/init_tasks.cpp +++ b/plugins/builtin/source/content/init_tasks.cpp @@ -59,7 +59,7 @@ namespace hex::plugin::builtin { ContentRegistry::Settings::write("hex.builtin.setting.general", "hex.builtin.setting.general.uuid", uuid); } - TaskManager::createBackgroundTask("Sending statistics..."_lang, [uuid, versionString](auto&) { + TaskManager::createBackgroundTask("hex.builtin.task.sending_statistics"_lang, [uuid, versionString](auto&) { // To avoid potentially flooding our database with lots of dead users // from people just visiting the website, don't send telemetry data from // the web version @@ -94,7 +94,7 @@ namespace hex::plugin::builtin { } bool checkForUpdates() { - TaskManager::createBackgroundTask("Checking for updates"_lang, [](auto&) { checkForUpdatesSync(); }); + TaskManager::createBackgroundTask("hex.builtin.task.check_updates"_lang, [](auto&) { checkForUpdatesSync(); }); return true; } diff --git a/plugins/builtin/source/content/main_menu_items.cpp b/plugins/builtin/source/content/main_menu_items.cpp index 5ffaf2cd2..67c02913f 100644 --- a/plugins/builtin/source/content/main_menu_items.cpp +++ b/plugins/builtin/source/content/main_menu_items.cpp @@ -214,7 +214,7 @@ namespace hex::plugin::builtin { for (const auto &formatter : ContentRegistry::DataFormatter::impl::getExportMenuEntries()) { if (ImGui::MenuItem(Lang(formatter.unlocalizedName), nullptr, false, ImHexApi::Provider::get()->getActualSize() > 0)) { fs::openFileBrowser(fs::DialogMode::Save, {}, [&formatter](const auto &path) { - TaskManager::createTask("Exporting data"_lang, TaskManager::NoProgress, [&formatter, path](auto&){ + TaskManager::createTask("hex.builtin.task.exporting_data"_lang, TaskManager::NoProgress, [&formatter, path](auto&){ auto provider = ImHexApi::Provider::get(); auto selection = ImHexApi::HexEditor::getSelection() .value_or( diff --git a/plugins/builtin/source/content/recent.cpp b/plugins/builtin/source/content/recent.cpp index 8fbbad834..25703e71f 100644 --- a/plugins/builtin/source/content/recent.cpp +++ b/plugins/builtin/source/content/recent.cpp @@ -149,7 +149,7 @@ namespace hex::plugin::builtin::recent { } void updateRecentEntries() { - TaskManager::createBackgroundTask("Updating recent files"_lang, [](auto&) { + TaskManager::createBackgroundTask("hex.builtin.task.updating_recents"_lang, [](auto&) { if (s_recentEntriesUpdating) return; diff --git a/plugins/builtin/source/content/views/view_data_inspector.cpp b/plugins/builtin/source/content/views/view_data_inspector.cpp index d7622614e..ecb4dcc90 100644 --- a/plugins/builtin/source/content/views/view_data_inspector.cpp +++ b/plugins/builtin/source/content/views/view_data_inspector.cpp @@ -57,7 +57,7 @@ namespace hex::plugin::builtin { } void ViewDataInspector::updateInspectorRows() { - m_updateTask = TaskManager::createBackgroundTask("Update Inspector"_lang, [this](auto &) { + m_updateTask = TaskManager::createBackgroundTask(hex.builtin.task.updating_inspector"_lang, [this](auto &) { this->updateInspectorRowsTask(); }); } diff --git a/plugins/builtin/source/content/views/view_data_processor.cpp b/plugins/builtin/source/content/views/view_data_processor.cpp index 9b60d49c3..32f788923 100644 --- a/plugins/builtin/source/content/views/view_data_processor.cpp +++ b/plugins/builtin/source/content/views/view_data_processor.cpp @@ -528,7 +528,7 @@ namespace hex::plugin::builtin { // Reset any potential node errors workspace.currNodeError.reset(); - m_evaluationTask = TaskManager::createTask("Evaluating Nodes..."_lang, 0, [this, workspace = &workspace](Task& task) { + m_evaluationTask = TaskManager::createTask("hex.builtin.task.evaluating_nodes"_lang, 0, [this, workspace = &workspace](Task& task) { task.setInterruptCallback([]{ dp::Node::interrupt(); }); diff --git a/plugins/builtin/source/content/views/view_find.cpp b/plugins/builtin/source/content/views/view_find.cpp index 042924760..15c28283d 100644 --- a/plugins/builtin/source/content/views/view_find.cpp +++ b/plugins/builtin/source/content/views/view_find.cpp @@ -924,7 +924,7 @@ namespace hex::plugin::builtin { m_filterTask.interrupt(); if (!m_currFilter->empty()) { - m_filterTask = TaskManager::createTask("Filtering"_lang, currOccurrences.size(), [this, provider, &currOccurrences](Task &task) { + m_filterTask = TaskManager::createTask("hex.builtin.task.filtering_data"_lang, currOccurrences.size(), [this, provider, &currOccurrences](Task &task) { u64 progress = 0; std::erase_if(currOccurrences, [this, provider, &task, &progress](const auto ®ion) { task.update(progress); diff --git a/plugins/builtin/source/content/views/view_hex_editor.cpp b/plugins/builtin/source/content/views/view_hex_editor.cpp index eb81f3cf3..dbee42267 100644 --- a/plugins/builtin/source/content/views/view_hex_editor.cpp +++ b/plugins/builtin/source/content/views/view_hex_editor.cpp @@ -1055,7 +1055,7 @@ namespace hex::plugin::builtin { ui::PopupFileChooser::open(basePaths, paths, std::vector{ {"Thingy Table File", "tbl"} }, false, [this](const auto &path) { - TaskManager::createTask("Loading encoding file"_lang, 0, [this, path](auto&) { + TaskManager::createTask("hex.builtin.task.loading_encoding_file"_lang, 0, [this, path](auto&) { auto encoding = EncodingFile(EncodingFile::Type::Thingy, path); ImHexApi::Provider::markDirty(); diff --git a/plugins/builtin/source/content/views/view_pattern_editor.cpp b/plugins/builtin/source/content/views/view_pattern_editor.cpp index 58989e660..a0c2e9626 100644 --- a/plugins/builtin/source/content/views/view_pattern_editor.cpp +++ b/plugins/builtin/source/content/views/view_pattern_editor.cpp @@ -558,7 +558,7 @@ namespace hex::plugin::builtin { auto code = m_textEditor.GetText(); EventPatternEditorChanged::post(code); - TaskManager::createBackgroundTask("Pattern Parsing"_lang, [this, code, provider](auto &){ + TaskManager::createBackgroundTask("hex.builtin.task.parsing_pattern"_lang, [this, code, provider](auto &){ this->parsePattern(code, provider); if (m_runAutomatically) @@ -1330,7 +1330,7 @@ namespace hex::plugin::builtin { if (m_shouldAnalyze) { m_shouldAnalyze = false; - m_analysisTask = TaskManager::createBackgroundTask("Analyzing file content"_lang, [this, provider](const Task &task) { + m_analysisTask = TaskManager::createBackgroundTask("hex.builtin.task.analyzing_data"_lang, [this, provider](const Task &task) { if (!m_autoLoadPatterns) return; @@ -1584,7 +1584,7 @@ namespace hex::plugin::builtin { m_textEditor.SetText(code); m_sourceCode.set(provider, code); - TaskManager::createBackgroundTask("Parse pattern"_lang, [this, code, provider](auto&) { this->parsePattern(code, provider); }); + TaskManager::createBackgroundTask("hex.builtin.task.parsing_pattern"_lang, [this, code, provider](auto&) { this->parsePattern(code, provider); }); } } diff --git a/plugins/builtin/source/content/views/view_store.cpp b/plugins/builtin/source/content/views/view_store.cpp index b9b628021..4a02447a3 100644 --- a/plugins/builtin/source/content/views/view_store.cpp +++ b/plugins/builtin/source/content/views/view_store.cpp @@ -197,7 +197,7 @@ namespace hex::plugin::builtin { ImGui::SameLine(ImGui::GetWindowWidth() - ImGui::GetCursorPosX() - 25_scaled); ImGui::BeginDisabled(m_updateAllTask.isRunning() || m_updateCount == 0); if (ImGuiExt::IconButton(ICON_VS_CLOUD_DOWNLOAD, ImGui::GetStyleColorVec4(ImGuiCol_Text))) { - m_updateAllTask = TaskManager::createTask("Update All..."_lang, m_updateCount, [this](auto &task) { + m_updateAllTask = TaskManager::createTask("hex.builtin.task.updating_store"_lang, m_updateCount, [this](auto &task) { for (auto &category : m_categories) { for (auto &entry : category.entries) { if (entry.hasUpdate) { diff --git a/plugins/builtin/source/content/welcome_screen.cpp b/plugins/builtin/source/content/welcome_screen.cpp index a3e9b7585..d1a5a38b1 100644 --- a/plugins/builtin/source/content/welcome_screen.cpp +++ b/plugins/builtin/source/content/welcome_screen.cpp @@ -96,7 +96,7 @@ namespace hex::plugin::builtin { } } - TaskManager::createBackgroundTask("Upload Crash report"_lang, [path = m_logFilePath, data](auto&){ + TaskManager::createBackgroundTask("hex.builtin.task.uploading_crash"_lang, [path = m_logFilePath, data](auto&){ HttpRequest request("POST", ImHexApiURL + std::string("/crash_upload")); request.uploadFile(std::vector(data.begin(), data.end()), "file", path.filename()).wait(); }); @@ -667,7 +667,7 @@ namespace hex::plugin::builtin { auto allowNetworking = ContentRegistry::Settings::read("hex.builtin.setting.general", "hex.builtin.setting.general.network_interface", false) && ContentRegistry::Settings::read("hex.builtin.setting.general", "hex.builtin.setting.general.server_contact", 0) != 0; if (!s_infoBannerTexture.isValid() && allowNetworking) { - TaskManager::createBackgroundTask("Load banner"_lang, [](auto&) { + TaskManager::createBackgroundTask("hex.builtin.task.loading_banner"_lang, [](auto&) { HttpRequest request("GET", ImHexApiURL + hex::format("/info/{}/image", hex::toLower(ImHexApi::System::getOSName()))); diff --git a/plugins/diffing/romfs/lang/en_US.json b/plugins/diffing/romfs/lang/en_US.json index 42f472b01..f4e898e71 100644 --- a/plugins/diffing/romfs/lang/en_US.json +++ b/plugins/diffing/romfs/lang/en_US.json @@ -16,6 +16,7 @@ "hex.diffing.view.diff.removed": "Removed", "hex.diffing.view.diff.algorithm": "Diffing Algorithm", "hex.diffing.view.diff.settings": "No settings available", - "hex.diffing.view.diff.settings.no_settings": "No settings available" + "hex.diffing.view.diff.settings.no_settings": "No settings available", + "hex.diffing.view.diff.task.diffing": "Diffing data..." } } \ No newline at end of file diff --git a/plugins/diffing/source/content/views/view_diff.cpp b/plugins/diffing/source/content/views/view_diff.cpp index d1da77700..275478eae 100644 --- a/plugins/diffing/source/content/views/view_diff.cpp +++ b/plugins/diffing/source/content/views/view_diff.cpp @@ -93,7 +93,7 @@ namespace hex::plugin::diffing { void ViewDiff::analyze(prv::Provider *providerA, prv::Provider *providerB) { auto commonSize = std::max(providerA->getActualSize(), providerB->getActualSize()); - m_diffTask = TaskManager::createTask("Diffing..."_lang, commonSize, [this, providerA, providerB](Task &) { + m_diffTask = TaskManager::createTask("hex.diffing.view.diff.task.diffing"_lang, commonSize, [this, providerA, providerB](Task &) { auto differences = m_algorithm->analyze(providerA, providerB); auto providers = ImHexApi::Provider::getProviders(); diff --git a/plugins/script_loader/romfs/lang/en_US.json b/plugins/script_loader/romfs/lang/en_US.json index 2ab930815..054774f8d 100644 --- a/plugins/script_loader/romfs/lang/en_US.json +++ b/plugins/script_loader/romfs/lang/en_US.json @@ -5,6 +5,8 @@ "translations": { "hex.script_loader.menu.run_script": "Run Script...", "hex.script_loader.menu.loading": "Loading...", - "hex.script_loader.menu.no_scripts": "No scripts found" + "hex.script_loader.menu.no_scripts": "No scripts found", + "hex.script_loader.task.updating": "Updating scripts...", + "hex.script_loader.task.running": "Running script..." } } \ No newline at end of file diff --git a/plugins/script_loader/source/plugin_script_loader.cpp b/plugins/script_loader/source/plugin_script_loader.cpp index c0c31a648..5e5238886 100644 --- a/plugins/script_loader/source/plugin_script_loader.cpp +++ b/plugins/script_loader/source/plugin_script_loader.cpp @@ -91,7 +91,7 @@ namespace { if (menuJustOpened) { menuJustOpened = false; if (!updaterTask.isRunning()) { - updaterTask = TaskManager::createBackgroundTask("Updating Scripts..."_lang, [] (auto&) { + updaterTask = TaskManager::createBackgroundTask("hex.script_loader.task.updating"_lang, [] (auto&) { scripts = loadAllScripts(); }); } @@ -109,7 +109,7 @@ namespace { continue; if (ImGui::MenuItem(name.c_str(), loader->getTypeName().c_str())) { - runnerTask = TaskManager::createTask("Running script..."_lang, TaskManager::NoProgress, [entryPoint](auto&) { + runnerTask = TaskManager::createTask("hex.script_loader.task.running"_lang, TaskManager::NoProgress, [entryPoint](auto&) { entryPoint(); }); } @@ -123,7 +123,7 @@ namespace { return !runnerTask.isRunning(); }); - updaterTask = TaskManager::createBackgroundTask("Updating Scripts..."_lang, [] (auto&) { + updaterTask = TaskManager::createBackgroundTask("hex.script_loader.task.updating"_lang, [] (auto&) { scripts = loadAllScripts(); }); } diff --git a/plugins/visualizers/romfs/lang/en_US.json b/plugins/visualizers/romfs/lang/en_US.json index 8aa8e6ef1..d37d6a6fb 100644 --- a/plugins/visualizers/romfs/lang/en_US.json +++ b/plugins/visualizers/romfs/lang/en_US.json @@ -16,6 +16,7 @@ "hex.visualizers.pl_visualizer.coordinates.longitude": "Longitude", "hex.visualizers.pl_visualizer.coordinates.query": "Find address", "hex.visualizers.pl_visualizer.coordinates.querying": "Querying address...", - "hex.visualizers.pl_visualizer.coordinates.querying_no_address": "No address found" + "hex.visualizers.pl_visualizer.coordinates.querying_no_address": "No address found", + "hex.visualizers.pl_visualizer.task.visualizing": "Visualizing data..." } } diff --git a/plugins/visualizers/source/content/pl_visualizers/sound.cpp b/plugins/visualizers/source/content/pl_visualizers/sound.cpp index 23c373bab..de163496f 100644 --- a/plugins/visualizers/source/content/pl_visualizers/sound.cpp +++ b/plugins/visualizers/source/content/pl_visualizers/sound.cpp @@ -32,7 +32,7 @@ namespace hex::plugin::visualizers { if (shouldReset) { waveData.clear(); - resetTask = TaskManager::createTask("Visualizing..."_lang, TaskManager::NoProgress, [=](Task &) { + resetTask = TaskManager::createTask("hex.visualizers.pl_visualizer.task.visualizing"_lang, TaskManager::NoProgress, [=](Task &) { ma_device_stop(&audioDevice); waveData = patternToArray(wavePattern.get()); sampledData = sampleData(waveData, 300_scaled * 4); diff --git a/plugins/windows/romfs/lang/en_US.json b/plugins/windows/romfs/lang/en_US.json index 8c965eeca..38a8ef973 100644 --- a/plugins/windows/romfs/lang/en_US.json +++ b/plugins/windows/romfs/lang/en_US.json @@ -23,6 +23,7 @@ "hex.windows.view.tty_console.send_eot": "Send EOT", "hex.windows.view.tty_console.send_etx": "Send ETX", "hex.windows.view.tty_console.send_sub": "Send SUB", - "hex.windows.view.tty_console.stop_bits": "Stop bits" + "hex.windows.view.tty_console.stop_bits": "Stop bits", + "hex.windows.view.tty_console.task.transmitting": "Transmitting data..." } } \ No newline at end of file diff --git a/plugins/windows/source/views/view_tty_console.cpp b/plugins/windows/source/views/view_tty_console.cpp index 3995153ba..6b38676bb 100644 --- a/plugins/windows/source/views/view_tty_console.cpp +++ b/plugins/windows/source/views/view_tty_console.cpp @@ -299,7 +299,7 @@ namespace hex::plugin::windows { if (m_transmitting) return; - TaskManager::createBackgroundTask("Transmitting data"_lang, [&, this](auto&) { + TaskManager::createBackgroundTask("hex.windows.view.tty_console.task.transmitting"_lang, [&, this](auto&) { OVERLAPPED overlapped = { }; overlapped.hEvent = ::CreateEvent(nullptr, true, false, nullptr);