Debugger: Split debugger event actions strings for easier translation

This commit is contained in:
chaoticgd 2025-08-24 12:46:55 +01:00 committed by Ty
parent a92297ceec
commit f65c1dd5bc
3 changed files with 13 additions and 10 deletions

View File

@ -38,7 +38,8 @@ namespace DebuggerEvents
bool switch_to_tab = true;
static constexpr const char* ACTION_PREFIX = QT_TRANSLATE_NOOP("DebuggerEvents", "Go to in");
static constexpr const char* ACTION_STRING = QT_TRANSLATE_NOOP("DebuggerEvents", "Go to in %1");
static constexpr const char* ACTION_OVERFLOW_STRING = QT_TRANSLATE_NOOP("DebuggerEvents", "Go to in...");
};
// The state of the VM has changed and views should be updated to reflect
@ -53,6 +54,7 @@ namespace DebuggerEvents
u32 address = 0;
bool switch_to_tab = true;
static constexpr const char* ACTION_PREFIX = QT_TRANSLATE_NOOP("DebuggerEvents", "Add to");
static constexpr const char* ACTION_STRING = QT_TRANSLATE_NOOP("DebuggerEvents", "Add to %1");
static constexpr const char* ACTION_OVERFLOW_STRING = QT_TRANSLATE_NOOP("DebuggerEvents", "Add to...");
};
} // namespace DebuggerEvents

View File

@ -257,7 +257,8 @@ std::vector<QAction*> DebuggerView::createEventActionsImplementation(
u32 max_top_level_actions,
bool skip_self,
const char* event_type,
const char* action_prefix,
const char* action_string,
const char* action_overflow_string,
std::function<const DebuggerEvents::Event*()> event_func)
{
if (!g_debugger_window)
@ -278,8 +279,7 @@ std::vector<QAction*> DebuggerView::createEventActionsImplementation(
QMenu* submenu = nullptr;
if (receivers.size() > max_top_level_actions)
{
QString title_format = QCoreApplication::translate("DebuggerEvent", "%1...");
submenu = new QMenu(title_format.arg(QCoreApplication::translate("DebuggerEvent", action_prefix)), menu);
submenu = new QMenu(QCoreApplication::translate("DebuggerEvents", action_overflow_string), menu);
}
std::vector<QAction*> actions;
@ -290,9 +290,8 @@ std::vector<QAction*> DebuggerView::createEventActionsImplementation(
QAction* action;
if (!submenu || i + 1 < max_top_level_actions)
{
QString title_format = QCoreApplication::translate("DebuggerEvent", "%1 %2");
QString event_title = QCoreApplication::translate("DebuggerEvent", action_prefix);
QString title = title_format.arg(event_title).arg(receiver->displayName());
QString title_format = QCoreApplication::translate("DebuggerEvents", action_string);
QString title = title_format.arg(receiver->displayName());
action = new QAction(title, menu);
menu->addAction(action);
}

View File

@ -127,7 +127,8 @@ public:
u32 max_top_level_actions = 5)
{
return createEventActionsImplementation(
menu, max_top_level_actions, skip_self, typeid(Event).name(), Event::ACTION_PREFIX,
menu, max_top_level_actions, skip_self, typeid(Event).name(),
Event::ACTION_STRING, Event::ACTION_OVERFLOW_STRING,
[event_func]() -> DebuggerEvents::Event* {
static std::optional<Event> event;
event = event_func();
@ -176,7 +177,8 @@ private:
u32 max_top_level_actions,
bool skip_self,
const char* event_type,
const char* action_prefix,
const char* action_string,
const char* action_overflow_string,
std::function<const DebuggerEvents::Event*()> event_func);
// Used for sorting debugger views that have the same display name. Unique