summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSiebrand Mazeland <s.mazeland@xs4all.nl>2010-09-16 00:07:47 +0200
committerSiebrand Mazeland <s.mazeland@xs4all.nl>2010-09-16 00:07:47 +0200
commit85154a49d0eb3d401dadd20bda527219e75ba396 (patch)
treefd1876d17f1eeb7d391c091b12cad5db4f0e14ba /lib
parent95b534c5cee56602dffcc11121908c0f518cab6d (diff)
Add plural support for minutes/hours/days/months ago.
Reapply of revised b27882c9166191de4aaea298ba1b1a524cfe9ac7 that was reverted by Brion Vibber in 2d4c0f9a47f6534c578a37abe79670cec699caae.
Diffstat (limited to 'lib')
-rw-r--r--lib/util.php16
1 files changed, 8 insertions, 8 deletions
diff --git a/lib/util.php b/lib/util.php
index 89d2bf8c2..6d2e99b2a 100644
--- a/lib/util.php
+++ b/lib/util.php
@@ -1105,30 +1105,30 @@ function common_date_string($dt)
// TRANS: Used in notices to indicate when the notice was made compared to now.
return _('about a minute ago');
} else if ($diff < 3300) {
- // XXX: should support plural.
+ $minutes = round($diff/60);
// TRANS: Used in notices to indicate when the notice was made compared to now.
- return sprintf(_('about %d minutes ago'), round($diff/60));
+ return sprintf( ngettext('about one minute ago', 'about %d minutes ago', $minutes), $minutes);
} else if ($diff < 5400) {
// TRANS: Used in notices to indicate when the notice was made compared to now.
return _('about an hour ago');
} else if ($diff < 22 * 3600) {
- // XXX: should support plural.
+ $hours = round($diff/3600);
// TRANS: Used in notices to indicate when the notice was made compared to now.
- return sprintf(_('about %d hours ago'), round($diff/3600));
+ return sprintf( ngettext('about one hour ago', 'about %d hours ago', $hours), $hours);
} else if ($diff < 37 * 3600) {
// TRANS: Used in notices to indicate when the notice was made compared to now.
return _('about a day ago');
} else if ($diff < 24 * 24 * 3600) {
- // XXX: should support plural.
+ $days = round($diff/(24*3600));
// TRANS: Used in notices to indicate when the notice was made compared to now.
- return sprintf(_('about %d days ago'), round($diff/(24*3600)));
+ return sprintf( ngettext('about one day ago', 'about %d days ago', $days), $days);
} else if ($diff < 46 * 24 * 3600) {
// TRANS: Used in notices to indicate when the notice was made compared to now.
return _('about a month ago');
} else if ($diff < 330 * 24 * 3600) {
- // XXX: should support plural.
+ $months = round($diff/(30*24*3600));
// TRANS: Used in notices to indicate when the notice was made compared to now.
- return sprintf(_('about %d months ago'), round($diff/(30*24*3600)));
+ return sprintf( ngettext('about one month ago', 'about %d months ago',$months), $months);
} else if ($diff < 480 * 24 * 3600) {
// TRANS: Used in notices to indicate when the notice was made compared to now.
return _('about a year ago');