line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DTL::Fast::Filter::Ru::Pluralize; |
2
|
1
|
|
|
1
|
|
649
|
use strict; use utf8; use warnings FATAL => 'all'; |
|
1
|
|
|
1
|
|
2
|
|
|
1
|
|
|
1
|
|
23
|
|
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
23
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
31
|
|
3
|
1
|
|
|
1
|
|
5
|
use parent 'DTL::Fast::Filter::Pluralize'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
5
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
$DTL::Fast::FILTER_HANDLERS{'pluralize'} = __PACKAGE__; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
#@Override |
8
|
|
|
|
|
|
|
sub parse_parameters |
9
|
|
|
|
|
|
|
{ |
10
|
11
|
|
|
11
|
0
|
15
|
my $self = shift; |
11
|
2
|
|
|
|
|
11
|
push @{$self->{'parameter'}}, DTL::Fast::Variable->new('""') # specify suffix for one, two and five |
12
|
11
|
100
|
|
|
|
12
|
if not scalar @{$self->{'parameter'}}; |
|
11
|
|
|
|
|
32
|
|
13
|
11
|
|
|
|
|
21
|
$self->{'suffix'} = $self->{'parameter'}->[0]; |
14
|
11
|
|
|
|
|
35
|
return $self; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub pluralize |
18
|
|
|
|
|
|
|
{ |
19
|
11
|
|
|
11
|
0
|
14
|
my $self = shift; |
20
|
11
|
|
|
|
|
12
|
my $value = shift; |
21
|
11
|
|
|
|
|
14
|
my $suffix = shift; |
22
|
|
|
|
|
|
|
|
23
|
11
|
|
100
|
|
|
33
|
my $suffix_one = shift @$suffix // ''; |
24
|
11
|
|
100
|
|
|
33
|
my $suffix_two = shift @$suffix // ''; |
25
|
11
|
|
100
|
|
|
31
|
my $suffix_five = shift @$suffix // $suffix_two; |
26
|
|
|
|
|
|
|
|
27
|
11
|
|
|
|
|
22
|
my $last_digit = substr int($value), -1; |
28
|
11
|
|
|
|
|
14
|
my $amount = abs $value; |
29
|
|
|
|
|
|
|
|
30
|
11
|
100
|
100
|
|
|
68
|
if( $amount >= 10 and $amount <= 20 ) { |
|
|
100
|
100
|
|
|
|
|
|
|
100
|
|
|
|
|
|
31
|
1
|
|
|
|
|
2
|
$value = $suffix_five; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
elsif( $last_digit == 1 ) { |
34
|
3
|
|
|
|
|
4
|
$value = $suffix_one; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
elsif( $last_digit >= 2 and $last_digit <= 4 ) { |
37
|
4
|
|
|
|
|
7
|
$value = $suffix_two; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
else{ |
40
|
3
|
|
|
|
|
5
|
$value = $suffix_five; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
11
|
|
|
|
|
56
|
return $value; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
1; |