From 610e71b71b4c6ccdda80b49dcd0e6d6713116184 Mon Sep 17 00:00:00 2001 From: Bevan Weiss Date: Thu, 3 Sep 2020 17:19:27 +1000 Subject: [PATCH] Internationalisation updates Added description 'Never played' for games with no elapsed time indicated. Tidied up game list times to handle translation for larger unit of time in each time pairing. NOTE: Latin will be a problem (sorry for any native Latin speakers) --- rpcs3/rpcs3qt/localized.cpp | 83 ++++++++++++++++--------------------- 1 file changed, 36 insertions(+), 47 deletions(-) diff --git a/rpcs3/rpcs3qt/localized.cpp b/rpcs3/rpcs3qt/localized.cpp index ec1deb54eb..3b4ddadc97 100644 --- a/rpcs3/rpcs3qt/localized.cpp +++ b/rpcs3/rpcs3qt/localized.cpp @@ -8,66 +8,55 @@ QString Localized::GetVerboseTimeByMs(qint64 elapsed_ms, bool show_days) const { if (elapsed_ms <= 0) { - return ""; + return tr("Never played"); } const qint64 elapsed_seconds = (elapsed_ms / 1000) + ((elapsed_ms % 1000) > 0 ? 1 : 0); - qint64 hours = elapsed_seconds / 3600; - // 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 (show_days && hours >= 24) + qint64 days = 0; + if (show_days) { - const qint64 days = hours / 24; + days = hours / 24; hours = hours % 24; - - if (hours <= 0) - { - return tr("%n day(s)", "", days); - } - if (days == 1) - { - return tr("%0 day and %n hour(s)", "", hours).arg(days); - } - return tr("%0 days and %n hour(s)", "", hours).arg(days); } - const qint64 minutes = (elapsed_seconds % 3600) / 60; const qint64 seconds = (elapsed_seconds % 3600) % 60; - if (hours <= 0) + QString str_days = tr("%Ln day(s)", "", days); + QString str_hours = tr("%Ln hour(s)", "", hours); + QString str_minutes = tr("%Ln minute(s)", "", minutes); + QString str_seconds = tr("%Ln second(s)", "", seconds); + + if (days != 0) { - if (minutes <= 0) - { - return tr("%n second(s)", "", seconds); - } - - if (seconds <= 0) - { - return tr("%n minute(s)", "", minutes); - } - - if (minutes == 1) - { - return tr("%0 minute and %n second(s)", "", seconds).arg(minutes); - } - - return tr("%0 minutes and %n second(s)", "", seconds).arg(minutes); + if (hours == 0) + return str_days; + else + return tr("%0 and %1", "Days and hours").arg(str_days).arg(str_hours); } - - if (minutes <= 0) + else { - return tr("%n hour(s)", "", hours); + if (hours != 0) + { + if (minutes == 0) + return str_hours; + else + return tr("%0 and %1", "Hours and minutes").arg(str_hours).arg(str_minutes); + } + else + { + if (minutes != 0) + { + if (seconds != 0) + return tr("%0 and %1", "Minutes and seconds").arg(str_minutes).arg(str_seconds); + else + return str_minutes; + } + else + { + return str_seconds; + } + } } - - if (hours == 1) - { - return tr("%0 hour and %n minute(s)", "", minutes).arg(hours); - } - - return tr("%0 hours and %n minute(s)", "", minutes).arg(hours); }