line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MooX::Locale::TextDomain::OO; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
26421
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
55
|
|
4
|
2
|
|
|
2
|
|
8
|
use warnings FATAL => 'all'; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
90
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = "0.001"; |
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
13
|
use Carp ("croak"); |
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
83
|
|
9
|
2
|
|
|
2
|
|
460
|
use Locale::TextDomain::OO (); |
|
2
|
|
|
|
|
116417
|
|
|
2
|
|
|
|
|
38
|
|
10
|
2
|
|
|
2
|
|
12
|
use Scalar::Util ("blessed"); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
93
|
|
11
|
|
|
|
|
|
|
|
12
|
2
|
|
|
2
|
|
11
|
use Moo::Role; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
13
|
|
13
|
|
|
|
|
|
|
with "MooX::Locale::Passthrough"; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 NAME |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
MooX::Locale::TextDomain::OO - provide API used in translator modules without translating |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 SYNOPSIS |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
{ package WonderBar; |
22
|
|
|
|
|
|
|
use Moo; |
23
|
|
|
|
|
|
|
with "MooX::Locale::TextDomain::OO"; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub tell_me { my $self = shift; $self->__("Hello world"); } |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
WonderBar->new->tell_me; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 DESCRIPTION |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
C |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head1 OVERLOADED METHODS |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head2 __ MSGID |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
returns translation for MSGID |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=cut |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
has localizer => (is => "lazy"); |
43
|
|
|
|
|
|
|
|
44
|
0
|
|
|
0
|
|
|
sub _build_localizer { Locale::TextDomain::OO->instance() } |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
around __ => sub { |
47
|
|
|
|
|
|
|
my ($next, $self, $msgid) = @_; |
48
|
|
|
|
|
|
|
my $loc = blessed $self ? $self->localizer : $self->_build_localizer; |
49
|
|
|
|
|
|
|
$loc->translate(undef, $msgid); |
50
|
|
|
|
|
|
|
}; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head2 __n MSGID, MSGID_PLURAL, COUNT |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
returns translation for MSGID when count is equal 1, translation for MSGID_PLURAL otherwise |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=cut |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
around __n => sub { |
59
|
|
|
|
|
|
|
my ($next, $self, $msgid_sin, $msgid_plu, $count) = @_; |
60
|
|
|
|
|
|
|
my $loc = blessed $self ? $self->localizer : $self->_build_localizer; |
61
|
|
|
|
|
|
|
$loc->translate(undef, $msgid_sin, $msgid_plu, $count, 1); |
62
|
|
|
|
|
|
|
}; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head2 __p MSGCTXT, MSGID |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
returns translation for MSGID in MSGCTXT context |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=cut |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
around __p => sub { |
71
|
|
|
|
|
|
|
my ($next, $self, $ctx, $msgid) = @_; |
72
|
|
|
|
|
|
|
my $loc = blessed $self ? $self->localizer : $self->_build_localizer; |
73
|
|
|
|
|
|
|
$loc->translate($ctx, $msgid); |
74
|
|
|
|
|
|
|
}; |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 AUTHOR |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Jens Rehsack, C<< >> |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 BUGS |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
Please report any bugs or feature requests to |
83
|
|
|
|
|
|
|
C, or through the web interface at |
84
|
|
|
|
|
|
|
L. |
85
|
|
|
|
|
|
|
I will be notified, and then you'll automatically be notified of progress |
86
|
|
|
|
|
|
|
on your bug as I make changes. |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 SUPPORT |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
perldoc MooX::Locale::TextDomain::OO |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
You can also look for information at: |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=over 4 |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
L |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
L |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=item * CPAN Ratings |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
L |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=item * Search CPAN |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
L |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=back |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
Copyright 2017 Jens Rehsack. |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
121
|
|
|
|
|
|
|
under the terms of either: the GNU General Public License as published |
122
|
|
|
|
|
|
|
by the Free Software Foundation; or the Artistic License. |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
See http://dev.perl.org/licenses/ for more information. |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=cut |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
1; |