summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2009-10-07 09:13:15 +0200
committerYorhel <git@yorhel.nl>2009-10-07 09:13:15 +0200
commit9afed91c8196a8d35fc33ec23a214cabb58c45a7 (patch)
tree9929432d627c31336c533a622a5bdd67e993feed /lib
parent519b13787e33f1b8edb3d0f3b018339410b48371 (diff)
L10N: Generalized age() for all languages by using maketext() internally
This way the translators can TL/improve their own translation of the age display, instead of asking me to fix it.
Diffstat (limited to 'lib')
-rw-r--r--lib/VNDB/L10N.pm23
1 files changed, 4 insertions, 19 deletions
diff --git a/lib/VNDB/L10N.pm b/lib/VNDB/L10N.pm
index c2423f53..e19302ed 100644
--- a/lib/VNDB/L10N.pm
+++ b/lib/VNDB/L10N.pm
@@ -58,8 +58,9 @@ use warnings;
# Argument: unix timestamp
# Returns: age
sub age {
- my $a = time-$_[1];
- return sprintf '%d %s ago',
+ my($self, $time) = @_;
+ my $a = time-$time;
+ my @f =
$a > 60*60*24*365*2 ? ( $a/60/60/24/365, 'years' ) :
$a > 60*60*24*(365/12)*2 ? ( $a/60/60/24/(365/12), 'months' ) :
$a > 60*60*24*7*2 ? ( $a/60/60/24/7, 'weeks' ) :
@@ -67,6 +68,7 @@ use warnings;
$a > 60*60*2 ? ( $a/60/60, 'hours' ) :
$a > 60*2 ? ( $a/60, 'min' ) :
( $a, 'sec' );
+ return $self->maketext("_age_$f[1]", int $f[0]);
}
# argument: unix timestamp and optional format (compact/full)
@@ -135,23 +137,6 @@ use warnings;
return $couple if ($num % 10) >= 2 && ($num % 10) <= 4 && !(($num % 100) >= 12 && ($num % 100) <= 14);
return $lots;
}
-
- sub age {
- my $self = shift;
- my $a = time-shift;
- use utf8;
- my @l = (
- $a > 60*60*24*365*2 ? ( $a/60/60/24/365, 'год', 'года', 'лет' ) :
- $a > 60*60*24*(365/12)*2 ? ( $a/60/60/24/(365/12), 'месяц', 'месяца', 'месяцев' ) :
- $a > 60*60*24*7*2 ? ( $a/60/60/24/7, 'неделя', 'недели', 'недель' ) :
- $a > 60*60*24*2 ? ( $a/60/60/24, 'день', 'дня', 'дней' ) :
- $a > 60*60*2 ? ( $a/60/60, 'час', 'часа', 'часов' ) :
- $a > 60*2 ? ( $a/60, 'минута', 'минуты', 'минут' ) :
- ( $a, 'секунда', 'секунды', 'секунд' )
- );
- return sprintf '%d %s назад', $l[0], $self->quant(@l);
- }
-
}