line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DateTime::Format::Human::Duration::Locale; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# require DateTime::Format::Locale; |
4
|
|
|
|
|
|
|
|
5
|
3
|
|
|
3
|
|
16
|
use strict; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
119
|
|
6
|
3
|
|
|
3
|
|
15
|
use warnings; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
1840
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub calc_locale { |
9
|
30
|
|
|
30
|
0
|
57
|
my ($span, $loc) = @_; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# DateTime::Format::Locale:: |
12
|
30
|
|
|
|
|
119
|
my $final = determine_locale_from({ |
13
|
|
|
|
|
|
|
'base_object' => $span, |
14
|
|
|
|
|
|
|
'get_locale_from' => $loc, |
15
|
|
|
|
|
|
|
'locale_ns_path' => 'DateTime/Format/Human/Duration/Locale', # DateTime::Format::Human::Duration::Locale |
16
|
|
|
|
|
|
|
}); |
17
|
|
|
|
|
|
|
|
18
|
30
|
100
|
|
|
|
106
|
if ($final) { |
19
|
7
|
50
|
|
|
|
20
|
return $final if ref $final; # returned 'locale_cache' we created below |
20
|
|
|
|
|
|
|
|
21
|
7
|
|
|
|
|
14
|
my $ns = "DateTime::Format::Human::Duration::Locale::$final"; |
22
|
|
|
|
|
|
|
# get_human_span_from_units_array has been deprecated, but we'll |
23
|
|
|
|
|
|
|
# still support it. |
24
|
7
|
50
|
|
|
|
191
|
if ( $ns->can('get_human_span_from_units_array') ) { |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
25
|
0
|
|
|
|
|
0
|
$span->{'locale_cache'}{ $final } = $ns; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
elsif ( $ns->can('get_human_span_from_units') ) { |
28
|
2
|
|
|
|
|
6
|
$span->{'locale_cache'}{ $final } = $ns; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
elsif ( my $sub = $ns->can('get_human_span_hashref') ) { |
31
|
5
|
|
|
|
|
15
|
$span->{'locale_cache'}{ $final } = $sub->(); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
7
|
50
|
|
|
|
36
|
if ( exists $span->{'locale_cache'}{ $final } ) { |
35
|
7
|
|
|
|
|
46
|
return $span->{'locale_cache'}{ $final }; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
23
|
|
|
|
|
70
|
return ''; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# DateTime::Format::Locale:: |
43
|
|
|
|
|
|
|
sub determine_locale_from { |
44
|
30
|
|
|
30
|
0
|
36
|
my ($args_hr) = @_; |
45
|
|
|
|
|
|
|
|
46
|
30
|
100
|
|
|
|
89
|
return '' if !$args_hr->{'get_locale_from'}; |
47
|
|
|
|
|
|
|
|
48
|
12
|
100
|
|
|
|
69
|
if (ref $args_hr->{'get_locale_from'}) { |
49
|
2
|
|
|
|
|
3
|
my $ns = ref($args_hr->{'get_locale_from'}); |
50
|
|
|
|
|
|
|
|
51
|
2
|
100
|
33
|
|
|
18
|
if (exists $args_hr->{'get_locale_from'}{'locale'}) { |
|
|
50
|
|
|
|
|
|
52
|
1
|
50
|
|
|
|
5
|
$ns = exists $args_hr->{'get_locale_from'}{'locale'}{'id'} ? $args_hr->{'get_locale_from'}{'locale'}{'id'} : ref($args_hr->{'get_locale_from'}{'locale'}); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
elsif ($ns =~ m{^DateTime::Locale::} && exists $args_hr->{'get_locale_from'}{'id'}) { |
55
|
1
|
|
|
|
|
2
|
$ns = $args_hr->{'get_locale_from'}{'id'}; |
56
|
|
|
|
|
|
|
} |
57
|
2
|
|
|
|
|
8
|
($args_hr->{'get_locale_from'}) = reverse split /::/, $ns; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
12
|
|
|
|
|
56
|
my ($short) = split(/[-_]+/,$args_hr->{'get_locale_from'}); |
61
|
|
|
|
|
|
|
|
62
|
12
|
|
|
|
|
22
|
my $final = ''; |
63
|
12
|
100
|
|
|
|
53
|
my @try = $args_hr->{'get_locale_from'} eq $short ? ($args_hr->{'get_locale_from'}) : ($args_hr->{'get_locale_from'}, $short); |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
NS: |
66
|
12
|
|
|
|
|
22
|
for my $locale ( @try ) { |
67
|
17
|
100
|
|
|
|
62
|
if ( exists $args_hr->{'base_object'}{'locale_cache'}{ $locale } ) { |
68
|
13
|
100
|
|
|
|
36
|
if ( $args_hr->{'base_object'}{'locale_cache'}{ $locale } ) { |
69
|
5
|
|
|
|
|
17
|
return $locale; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
else { |
72
|
8
|
|
|
|
|
16
|
next NS; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
4
|
|
|
|
|
12
|
$args_hr->{'locale_ns_path'} =~ s{/$}{}; |
77
|
4
|
|
|
|
|
15
|
my $path = "$args_hr->{'locale_ns_path'}/$locale\.pm"; |
78
|
|
|
|
|
|
|
|
79
|
4
|
100
|
66
|
|
|
31
|
if( exists $INC{$path} || eval { $args_hr->{'loads'}{$locale}++; require $path } ) { |
|
4
|
|
|
|
|
14
|
|
|
4
|
|
|
|
|
2695
|
|
80
|
2
|
|
|
|
|
462
|
$final = $locale; |
81
|
2
|
|
|
|
|
26
|
$args_hr->{'base_object'}{'locale_cache'}{ $locale } = 1; |
82
|
2
|
|
|
|
|
8
|
last NS; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
else { |
85
|
2
|
|
|
|
|
4
|
push @{$args_hr->{'errors'}{$locale}}, $@; |
|
2
|
|
|
|
|
8
|
|
86
|
2
|
|
|
|
|
11
|
$args_hr->{'base_object'}{'locale_cache'}{ $locale } = ''; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
7
|
|
|
|
|
21
|
return $final; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
1; |