line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Translate::Fluent::ResourceSet; |
2
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
3036
|
use Moo; |
|
6
|
|
|
|
|
64272
|
|
|
6
|
|
|
|
|
31
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
has resources => ( |
6
|
|
|
|
|
|
|
is => 'rw', |
7
|
|
|
|
|
|
|
default => sub { {} }, |
8
|
|
|
|
|
|
|
); |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub add_resource { |
11
|
70
|
|
|
70
|
1
|
166
|
my ($self, $resource) = @_; |
12
|
|
|
|
|
|
|
|
13
|
70
|
|
|
|
|
431
|
$self->resources->{ $resource->identifier } = $resource; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub translate { |
18
|
7
|
|
|
7
|
1
|
3305
|
my ($self, $res_id, $variables) = @_; |
19
|
|
|
|
|
|
|
|
20
|
7
|
|
|
|
|
24
|
my $res = $self->resources->{ $res_id }; |
21
|
|
|
|
|
|
|
|
22
|
7
|
100
|
100
|
|
|
48
|
return unless $res and $res->isa("Translate::Fluent::Elements::Message"); |
23
|
|
|
|
|
|
|
|
24
|
5
|
|
100
|
|
|
7
|
return $res->translate( { %{$variables//{}}, __resourceset => $self} ); |
|
5
|
|
|
|
|
32
|
|
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub get_term { |
28
|
7
|
|
|
7
|
1
|
605
|
my ($self, $term_id) = @_; |
29
|
|
|
|
|
|
|
|
30
|
7
|
|
|
|
|
16
|
my $res = $self->resources->{ $term_id }; |
31
|
7
|
100
|
|
|
|
27
|
return unless $res->isa("Translate::Fluent::Elements::Term"); |
32
|
|
|
|
|
|
|
|
33
|
6
|
|
|
|
|
13
|
return $res; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub get_message { |
37
|
3
|
|
|
3
|
1
|
6
|
my ($self, $message_id) = @_; |
38
|
|
|
|
|
|
|
|
39
|
3
|
|
|
|
|
8
|
my $res = $self->resources->{ $message_id }; |
40
|
3
|
50
|
|
|
|
8
|
return unless $res->isa("Translate::Fluent::Elements::Message"); |
41
|
|
|
|
|
|
|
|
42
|
3
|
|
|
|
|
7
|
return $res; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
1; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
__END__ |