Hook up plurality to OSD messages

This commit is contained in:
Silent 2021-03-12 21:40:24 +01:00
parent 948a6b530b
commit 6350bb0e36
No known key found for this signature in database
GPG key ID: AE53149BB0C45AF1
2 changed files with 56 additions and 9 deletions

View file

@ -41,6 +41,51 @@
</translation>
</message>
</context>
<context>
<name>OSDMessage</name>
<message numerus="yes">
<source>Loaded %n cheats from list.</source>
<translation>
<numerusform>Loaded %n cheat from list.</numerusform>
<numerusform>Loaded %n cheats from list.</numerusform>
</translation>
</message>
<message numerus="yes">
<source> %n cheats are enabled.</source>
<translation>
<numerusform> %n cheat is enabled.</numerusform>
<numerusform> %n cheats are enabled.</numerusform>
</translation>
</message>
<message numerus="yes">
<source>%n cheats are now active.</source>
<translation>
<numerusform>%n cheat is now active.</numerusform>
<numerusform>%n cheats are now active.</numerusform>
</translation>
</message>
<message numerus="yes">
<source>%n cheats are now inactive.</source>
<translation>
<numerusform>%n cheat is now inactive.</numerusform>
<numerusform>%n cheats are now inactive.</numerusform>
</translation>
</message>
<message numerus="yes">
<source>Loaded %n cheats from database.</source>
<translation>
<numerusform>Loaded %n cheat from database.</numerusform>
<numerusform>Loaded %n cheats from database.</numerusform>
</translation>
</message>
<message numerus="yes">
<source>Saved %n cheats to &apos;%s&apos;.</source>
<translation>
<numerusform>Saved %n cheat to &apos;%s&apos;.</numerusform>
<numerusform>Saved %n cheats to &apos;%s&apos;.</numerusform>
</translation>
</message>
</context>
<context>
<name>QtHostInterface</name>
<message numerus="yes">

View file

@ -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<CommonHostInterface::HostKeyCode>
@ -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;
}