[gnome-todo] get_string_for_date: Use "Yesterday" and "n days ago" correctly.



commit 2270a7b4a2700bcac250f34fb9fd324da2b9198a
Author: Rafal Luzynski <digitalfreak lingonborough com>
Date:   Thu Feb 15 00:10:23 2018 +0100

    get_string_for_date: Use "Yesterday" and "n days ago" correctly.
    
    Some languages don't have plurals, some reuse the singular form for
    numbers like 21, 31, 41...  Therefore if you want to display
    "Yesterday" instead of "1 day ago" you must do it explicitly.
    You can't rely on ngettext(), you can't assume that n == 1 is always
    singular and n != 1 is always plural.

 plugins/scheduled-panel/gtd-panel-scheduled.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
---
diff --git a/plugins/scheduled-panel/gtd-panel-scheduled.c b/plugins/scheduled-panel/gtd-panel-scheduled.c
index 8633483..4af8b76 100644
--- a/plugins/scheduled-panel/gtd-panel-scheduled.c
+++ b/plugins/scheduled-panel/gtd-panel-scheduled.c
@@ -92,9 +92,18 @@ get_string_for_date (GDateTime *dt,
 
   get_date_offset (dt, &days_diff, &years_diff);
 
-  if (days_diff < 0)
+  if (days_diff < -1)
     {
-      str = g_strdup_printf (g_dngettext (NULL, "Yesterday", "%d days ago", -days_diff), -days_diff);
+      /* Translators: This message will never be used with '1 day ago'
+       * but the singular form is required because some languages do not
+       * have plurals, some languages reuse the singular form for numbers
+       * like 21, 31, 41, etc.
+       */
+      str = g_strdup_printf (g_dngettext (NULL, "%d day ago", "%d days ago", -days_diff), -days_diff);
+    }
+  else if (days_diff == -1)
+    {
+      str = g_strdup (_("Yesterday"));
     }
   else if (days_diff == 0)
     {


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