From 8ed45a055360d6266eed695ab178727c57104a79 Mon Sep 17 00:00:00 2001 From: ipkpjersi <33754783+ipkpjersi@users.noreply.github.com> Date: Sun, 3 Nov 2019 15:22:23 -0500 Subject: [PATCH] Qt: Fixed plurals of time played strings (#6937) --- rpcs3/rpcs3qt/game_list_frame.cpp | 43 +++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/rpcs3/rpcs3qt/game_list_frame.cpp b/rpcs3/rpcs3qt/game_list_frame.cpp index 59922a4548..6635be4d47 100644 --- a/rpcs3/rpcs3qt/game_list_frame.cpp +++ b/rpcs3/rpcs3qt/game_list_frame.cpp @@ -380,26 +380,65 @@ QString game_list_frame::GetPlayTimeBySerial(const QString& serial) const qint64 minutes_played = (elapsed_seconds % 3600) / 60; const qint64 seconds_played = (elapsed_seconds % 3600) % 60; + // For anyone who was wondering why there need to be so many cases: + // 1. Using variables won't work for future localization due to varying sentence structure in different languages. + // 2. The provided Qt functionality only works if localization is already enabled + // 3. The provided Qt functionality only works for single variables + if (hours_played <= 0) { if (minutes_played <= 0) { + if (seconds_played == 1) + { + return tr("%0 second").arg(seconds_played); + } return tr("%0 seconds").arg(seconds_played); } if (seconds_played <= 0) { + if (minutes_played == 1) + { + return tr("%0 minute").arg(minutes_played); + } return tr("%0 minutes").arg(minutes_played); } - + if (minutes_played == 1 && seconds_played == 1) + { + return tr("%0 minute and %1 second").arg(minutes_played).arg(seconds_played); + } + if (minutes_played == 1) + { + return tr("%0 minute and %1 seconds").arg(minutes_played).arg(seconds_played); + } + if (seconds_played == 1) + { + return tr("%0 minutes and %1 second").arg(minutes_played).arg(seconds_played); + } return tr("%0 minutes and %1 seconds").arg(minutes_played).arg(seconds_played); } if (minutes_played <= 0) { + if (hours_played == 1) + { + return tr("%0 hour").arg(hours_played); + } return tr("%0 hours").arg(hours_played); } - + if (hours_played == 1 && minutes_played == 1) + { + return tr("%0 hour and %1 minute").arg(hours_played).arg(minutes_played); + } + if (hours_played == 1) + { + return tr("%0 hour and %1 minutes").arg(hours_played).arg(minutes_played); + } + if (minutes_played == 1) + { + return tr("%0 hours and %1 minute").arg(hours_played).arg(minutes_played); + } return tr("%0 hours and %1 minutes").arg(hours_played).arg(minutes_played); }