diff options
| author | Vaxry <43317083+vaxerski@users.noreply.github.com> | 2025-11-16 14:51:14 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-11-16 14:51:14 +0000 |
| commit | e616e595ae5c1af89a336e4e337a41b9855eaf6e (patch) | |
| tree | 328dd136e65963d1e47864af3feafcc304fc280d /src/managers/ANRManager.cpp | |
| parent | cb47eb1d11bbac1ebab8f9cd7a5f96a475eaab28 (diff) | |
i18n: init localization for ANR, Permissions and Notifications (#12316)
Adds localization support for en, it, pl and jp
---------
Co-authored-by: Mihai Fufezan <mihai@fufexan.net>
Co-authored-by: Aaron Blasko <blaskoazzolaaaron@gmail.com>
Diffstat (limited to 'src/managers/ANRManager.cpp')
| -rw-r--r-- | src/managers/ANRManager.cpp | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/src/managers/ANRManager.cpp b/src/managers/ANRManager.cpp index 65e0dea1..daab4d0a 100644 --- a/src/managers/ANRManager.cpp +++ b/src/managers/ANRManager.cpp @@ -8,6 +8,7 @@ #include "./eventLoop/EventLoopManager.hpp" #include "../config/ConfigValue.hpp" #include "../xwayland/XSurface.hpp" +#include "../i18n/Engine.hpp" using namespace Hyprutils::OS; @@ -83,7 +84,7 @@ void CANRManager::onTick() { if (data->missedResponses >= *PANRTHRESHOLD) { if (!data->isRunning() && !data->dialogSaidWait) { - data->runDialog("Application Not Responding", firstWindow->m_title, firstWindow->m_class, data->getPid()); + data->runDialog(firstWindow->m_title, firstWindow->m_class, data->getPid()); for (const auto& w : g_pCompositor->m_windows) { if (!w->m_isMapped) @@ -176,16 +177,29 @@ CANRManager::SANRData::~SANRData() { killDialog(); } -void CANRManager::SANRData::runDialog(const std::string& title, const std::string& appName, const std::string appClass, pid_t dialogWmPID) { +void CANRManager::SANRData::runDialog(const std::string& appName, const std::string appClass, pid_t dialogWmPID) { if (dialogBox && dialogBox->isRunning()) killDialog(); - dialogBox = CAsyncDialogBox::create(title, - std::format("Application {} with class of {} is not responding.\nWhat do you want to do with it?", appName.empty() ? "unknown" : appName, - appClass.empty() ? "unknown" : appClass), - std::vector<std::string>{"Terminate", "Wait"}); - - dialogBox->open()->then([dialogWmPID, this](SP<CPromiseResult<std::string>> r) { + const auto OPTION_TERMINATE_STR = I18n::i18nEngine()->localize(I18n::TXT_KEY_ANR_OPTION_TERMINATE, {}); + const auto OPTION_WAIT_STR = I18n::i18nEngine()->localize(I18n::TXT_KEY_ANR_OPTION_WAIT, {}); + + dialogBox = + CAsyncDialogBox::create(I18n::i18nEngine()->localize(I18n::TXT_KEY_ANR_TITLE, {}), + I18n::i18nEngine()->localize(I18n::TXT_KEY_ANR_CONTENT, + { + // + {"class", appClass.empty() ? I18n::i18nEngine()->localize(I18n::TXT_KEY_ANR_PROP_UNKNOWN, {}) : appClass}, // + {"title", appName.empty() ? I18n::i18nEngine()->localize(I18n::TXT_KEY_ANR_PROP_UNKNOWN, {}) : appName} // + }), + std::vector<std::string>{ + // + OPTION_TERMINATE_STR, // + OPTION_WAIT_STR // + } // + ); + + dialogBox->open()->then([dialogWmPID, this, OPTION_TERMINATE_STR, OPTION_WAIT_STR](SP<CPromiseResult<std::string>> r) { if (r->hasError()) { Debug::log(ERR, "CANRManager::SANRData::runDialog: error spawning dialog"); return; @@ -193,9 +207,9 @@ void CANRManager::SANRData::runDialog(const std::string& title, const std::strin const auto& result = r->result(); - if (result.starts_with("Terminate")) + if (result.starts_with(OPTION_TERMINATE_STR)) ::kill(dialogWmPID, SIGKILL); - else if (result.starts_with("Wait")) + else if (result.starts_with(OPTION_WAIT_STR)) dialogSaidWait = true; else Debug::log(ERR, "CANRManager::SANRData::runDialog: lambda: unrecognized result: {}", result); |
