[gnome-shell/T29763: 234/249] payg: Fix ngettext usage



commit 287e4fc661777289df789d20d7ea766ce12a46c7
Author: Matthew Leeds <matthew leeds endlessm com>
Date:   Fri Apr 24 12:01:18 2020 -0700

    payg: Fix ngettext usage
    
    Use ngettext properly so we have e.g. "1 day" not "1 days" in the
    message shown to the user after credit is added.
    
    https://phabricator.endlessm.com/T25995

 js/ui/payg.js | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)
---
diff --git a/js/ui/payg.js b/js/ui/payg.js
index ca49bd575a..e8aeba1747 100644
--- a/js/ui/payg.js
+++ b/js/ui/payg.js
@@ -639,35 +639,40 @@ function successMessage() {
     let seconds = Main.paygManager.lastTimeAdded;
     if (seconds < 60) {
         return Gettext.ngettext("%s second has been added to your Pay As You Go credit.",
-                                "%s seconds have been added to your Pay As You Go credit.")
+                                "%s seconds have been added to your Pay As You Go credit.",
+                                Math.floor(seconds))
                                 .format(Math.floor(seconds));
     }
 
     let minutes = Math.floor(seconds / 60);
     if (minutes < 120) {
         return Gettext.ngettext("%s minute has been added to your Pay As You Go credit.",
-                                "%s minutes have been added to your Pay As You Go credit.")
+                                "%s minutes have been added to your Pay As You Go credit.",
+                                Math.floor(minutes))
                                 .format(Math.floor(minutes));
     }
 
     let hours = Math.floor(minutes / 60);
     if (hours < 24) {
         return Gettext.ngettext("%s hour has been added to your Pay As You Go credit.",
-                                "%s hours have been added to your Pay As You Go credit.")
+                                "%s hours have been added to your Pay As You Go credit.",
+                                Math.floor(hours))
                                 .format(Math.floor(hours));
     }
 
     let days = Math.floor(hours / 24);
     if (days < 30) {
         return Gettext.ngettext("%s day has been added to your Pay As You Go credit.",
-                                "%s days have been added to your Pay As You Go credit.")
+                                "%s days have been added to your Pay As You Go credit.",
+                                Math.floor(days))
                                 .format(Math.floor(days));
     }
 
     let months = Math.floor(days / 30);
     if (months < 12) {
         return Gettext.ngettext("%s month has been added to your Pay As You Go credit.",
-                                "%s months have been added to your Pay As You Go credit.")
+                                "%s months have been added to your Pay As You Go credit.",
+                                Math.floor(months))
                                 .format(Math.floor(months));
     }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]