From 6350bb0e362b070ae70ea927ab58b6e9c0754182 Mon Sep 17 00:00:00 2001 From: Silent Date: Fri, 12 Mar 2021 21:40:24 +0100 Subject: [PATCH] Hook up plurality to OSD messages --- .../translations/duckstation-qt_en.ts | 45 +++++++++++++++++++ src/frontend-common/common_host_interface.cpp | 20 +++++---- 2 files changed, 56 insertions(+), 9 deletions(-) diff --git a/src/duckstation-qt/translations/duckstation-qt_en.ts b/src/duckstation-qt/translations/duckstation-qt_en.ts index 0df202fdc..d9f62f15a 100644 --- a/src/duckstation-qt/translations/duckstation-qt_en.ts +++ b/src/duckstation-qt/translations/duckstation-qt_en.ts @@ -41,6 +41,51 @@ + + OSDMessage + + Loaded %n cheats from list. + + Loaded %n cheat from list. + Loaded %n cheats from list. + + + + %n cheats are enabled. + + %n cheat is enabled. + %n cheats are enabled. + + + + %n cheats are now active. + + %n cheat is now active. + %n cheats are now active. + + + + %n cheats are now inactive. + + %n cheat is now inactive. + %n cheats are now inactive. + + + + Loaded %n cheats from database. + + Loaded %n cheat from database. + Loaded %n cheats from database. + + + + Saved %n cheats to '%s'. + + Saved %n cheat to '%s'. + Saved %n cheats to '%s'. + + + QtHostInterface diff --git a/src/frontend-common/common_host_interface.cpp b/src/frontend-common/common_host_interface.cpp index 365b6b0ed..4958ec047 100644 --- a/src/frontend-common/common_host_interface.cpp +++ b/src/frontend-common/common_host_interface.cpp @@ -1273,10 +1273,10 @@ void CommonHostInterface::DoToggleCheats() } cl->SetMasterEnable(!cl->GetMasterEnable()); - AddFormattedOSDMessage(10.0f, - cl->GetMasterEnable() ? TranslateString("OSDMessage", "%u cheats are now active.") : - TranslateString("OSDMessage", "%u cheats are now inactive."), - cl->GetEnabledCodeCount()); + AddOSDMessage(cl->GetMasterEnable() ? + TranslateStdString("OSDMessage", "%n cheats are now active.", "", cl->GetEnabledCodeCount()) : + TranslateStdString("OSDMessage", "%n cheats are now inactive.", "", cl->GetEnabledCodeCount()), + 10.0f); } std::optional @@ -3041,8 +3041,9 @@ bool CommonHostInterface::LoadCheatList(const char* filename) return false; } - AddFormattedOSDMessage(10.0f, TranslateString("OSDMessage", "Loaded %u cheats from list. %u cheats are enabled."), - cl->GetCodeCount(), cl->GetEnabledCodeCount()); + AddOSDMessage(TranslateStdString("OSDMessage", "Loaded %n cheats from list.", "", cl->GetCodeCount()) + + TranslateStdString("OSDMessage", " %n cheats are enabled.", "", cl->GetEnabledCodeCount()), + 10.0f); System::SetCheatList(std::move(cl)); return true; } @@ -3068,7 +3069,7 @@ bool CommonHostInterface::LoadCheatListFromDatabase() if (!cl->LoadFromPackage(System::GetRunningCode())) return false; - AddFormattedOSDMessage(10.0f, TranslateString("OSDMessage", "Loaded %u cheats from database."), cl->GetCodeCount()); + AddOSDMessage(TranslateStdString("OSDMessage", "Loaded %n cheats from database.", "", cl->GetCodeCount()), 10.0f); System::SetCheatList(std::move(cl)); return true; } @@ -3098,8 +3099,9 @@ bool CommonHostInterface::SaveCheatList(const char* filename) if (!System::GetCheatList()->SaveToPCSXRFile(filename)) return false; - AddFormattedOSDMessage(5.0f, TranslateString("OSDMessage", "Saved %u cheats to '%s'."), - System::GetCheatList()->GetCodeCount(), filename); + // This shouldn't be needed, but lupdate doesn't gather this string otherwise... + const u32 code_count = System::GetCheatList()->GetCodeCount(); + AddFormattedOSDMessage(5.0f, TranslateString("OSDMessage", "Saved %n cheats to '%s'.", "", code_count), filename); return true; }