aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/Utils.pm
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2012-10-08 22:38:13 +0100
committerMatthew Somerville <matthew@firefly.ukcod.org.uk>2012-10-08 22:38:26 +0100
commit2b0fc3749e9cf5d210718c0082606640b3148ae1 (patch)
tree57ca7cb1418cc898b545ffbcacce2af21304b21d /perllib/Utils.pm
parent7a3b06d61f63f34eed12029c974dc66d6ffbdc87 (diff)
Update .po file, and make prettify function do nget() properly.
Diffstat (limited to 'perllib/Utils.pm')
-rw-r--r--perllib/Utils.pm22
1 files changed, 16 insertions, 6 deletions
diff --git a/perllib/Utils.pm b/perllib/Utils.pm
index 8a4c4265d..0d088c87f 100644
--- a/perllib/Utils.pm
+++ b/perllib/Utils.pm
@@ -295,17 +295,27 @@ sub prettify_duration {
return _('less than a minute') if $s == 0;
}
my @out = ();
- _part(\$s, 60*60*24*7, _('%d week'), _('%d weeks'), \@out);
- _part(\$s, 60*60*24, _('%d day'), _('%d days'), \@out);
- _part(\$s, 60*60, _('%d hour'), _('%d hours'), \@out);
- _part(\$s, 60, _('%d minute'), _('%d minutes'), \@out);
+ _part(\$s, 60*60*24*7, \@out);
+ _part(\$s, 60*60*24, \@out);
+ _part(\$s, 60*60, \@out);
+ _part(\$s, 60, \@out);
return join(', ', @out);
}
sub _part {
- my ($s, $m, $w1, $w2, $o) = @_;
+ my ($s, $m, $o) = @_;
if ($$s >= $m) {
my $i = int($$s / $m);
- push @$o, sprintf(mySociety::Locale::nget($w1, $w2, $i), $i);
+ my $str;
+ if ($m == 60*60*24*7) {
+ $str = mySociety::Locale::nget("%d week", "%d weeks", $i);
+ } elsif ($m == 60*60*24) {
+ $str = mySociety::Locale::nget("%d day", "%d days", $i);
+ } elsif ($m == 60*60) {
+ $str = mySociety::Locale::nget("%d hour", "%d hours", $i);
+ } elsif ($m == 60) {
+ $str = mySociety::Locale::nget("%d minute", "%d minutes", $i);
+ }
+ push @$o, sprintf($str, $i);
$$s -= $i * $m;
}
}