line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Template::Plugin::Filter::I18N;
|
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
691
|
use strict;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
53
|
|
4
|
1
|
|
|
1
|
|
7
|
use warnings;
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
50
|
|
5
|
1
|
|
|
1
|
|
623
|
use Template::Plugin::Filter;
|
|
1
|
|
|
|
|
6102
|
|
|
1
|
|
|
|
|
34
|
|
6
|
1
|
|
|
1
|
|
8
|
use base qw( Template::Plugin::Filter );
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
74
|
|
7
|
1
|
|
|
1
|
|
748
|
use Locale::gettext;
|
|
1
|
|
|
|
|
13664
|
|
|
1
|
|
|
|
|
127
|
|
8
|
1
|
|
|
1
|
|
643
|
use POSIX;
|
|
1
|
|
|
|
|
5210
|
|
|
1
|
|
|
|
|
5
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.01';
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub init {
|
13
|
0
|
|
|
0
|
0
|
|
my ($self, @args) = @_;
|
14
|
|
|
|
|
|
|
|
15
|
0
|
|
|
|
|
|
my $conf = $args[0];
|
16
|
|
|
|
|
|
|
|
17
|
0
|
|
0
|
|
|
|
my $domain = $self->{_CONFIG}{domain} || $conf->{domain} || $self->{_CONTEXT}->throw(__PACKAGE__, 'undefined domain');
|
18
|
0
|
|
0
|
|
|
|
my $locale = $self->{_CONFIG}{locale} || $conf->{locale} || $self->{_CONTEXT}->throw(__PACKAGE__, 'undefined locale');
|
19
|
0
|
|
0
|
|
|
|
my $dir = $self->{_CONFIG}{dir} || $conf->{dir};
|
20
|
0
|
|
0
|
|
|
|
my $filter = $self->{_CONFIG}{filter} || $conf->{filter} || 'i18n';
|
21
|
|
|
|
|
|
|
|
22
|
0
|
|
|
|
|
|
setlocale(LC_MESSAGES, $locale);
|
23
|
|
|
|
|
|
|
|
24
|
0
|
|
|
|
|
|
$self->{domain} = Locale::gettext->domain($domain);
|
25
|
|
|
|
|
|
|
|
26
|
0
|
|
|
|
|
|
$self->{domain}->dir($dir);
|
27
|
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
|
$self->install_filter($filter);
|
29
|
|
|
|
|
|
|
|
30
|
0
|
|
|
|
|
|
return $self;
|
31
|
|
|
|
|
|
|
}
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub filter {
|
34
|
0
|
|
|
0
|
0
|
|
my ($self, $text, $params) = @_;
|
35
|
0
|
|
|
|
|
|
return $self->{domain}->get($text);
|
36
|
|
|
|
|
|
|
}
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
1;
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
__END__
|