| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package XUL::App::I18N; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
4441
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
39
|
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
198
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
#use lib 'tmplib/lib'; |
|
7
|
1
|
|
|
1
|
|
6
|
use base 'Locale::Maketext'; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
1297
|
|
|
8
|
1
|
|
|
1
|
|
20012
|
use Locale::Maketext::Lexicon (); |
|
|
1
|
|
|
|
|
3279
|
|
|
|
1
|
|
|
|
|
27
|
|
|
9
|
1
|
|
|
1
|
|
9
|
use File::Spec (); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
169
|
|
|
10
|
|
|
|
|
|
|
#use Smart::Comments; |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $Lang = []; |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub new { |
|
15
|
0
|
|
|
0
|
0
|
|
my $class = shift; |
|
16
|
0
|
|
|
|
|
|
my $self = {}; |
|
17
|
0
|
|
|
|
|
|
my $lang = $Lang; |
|
18
|
0
|
|
|
|
|
|
bless $self, $class; |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# XXX: this requires a full review, LML->get_handle is calling new |
|
21
|
|
|
|
|
|
|
# on I18N::lang each time, but we really shouldn't need to rerun |
|
22
|
|
|
|
|
|
|
# the import here. |
|
23
|
|
|
|
|
|
|
|
|
24
|
0
|
|
|
|
|
|
my @import = map { (Gettext => $_) } _get_file_patterns(); |
|
|
0
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
### @import |
|
27
|
|
|
|
|
|
|
### NEW BEGIN... |
|
28
|
0
|
|
|
|
|
|
Locale::Maketext::Lexicon->import( |
|
29
|
|
|
|
|
|
|
{ '*' => \@import, |
|
30
|
|
|
|
|
|
|
_decode => 1, |
|
31
|
|
|
|
|
|
|
_auto => 1, |
|
32
|
|
|
|
|
|
|
_style => 'gettext', |
|
33
|
|
|
|
|
|
|
} |
|
34
|
|
|
|
|
|
|
); |
|
35
|
|
|
|
|
|
|
### NEW END... |
|
36
|
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
my $lh = $class->get_handle(@$lang); |
|
38
|
|
|
|
|
|
|
#if (!defined $lh) { |
|
39
|
|
|
|
|
|
|
#die "Can't get I18N handle for @$lang"; |
|
40
|
|
|
|
|
|
|
#} |
|
41
|
|
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
|
$self->init; |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
my $loc_method = sub { |
|
45
|
|
|
|
|
|
|
# Retain compatibility with people using "-e _" etc. |
|
46
|
0
|
0
|
|
0
|
|
|
return \*_ unless @_; # Needed for perl 5.8 |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# When $_[0] is undef, return undef. When it is '', return ''. |
|
49
|
1
|
|
|
1
|
|
7
|
no warnings 'uninitialized'; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
171
|
|
|
50
|
0
|
0
|
|
|
|
|
return $_[0] unless (length $_[0]); |
|
51
|
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
local $@; |
|
53
|
|
|
|
|
|
|
# Force stringification to stop Locale::Maketext from choking on |
|
54
|
|
|
|
|
|
|
# things like DateTime objects. |
|
55
|
0
|
|
|
|
|
|
my @stringified_args = map {"$_"} @_; |
|
|
0
|
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
|
my $result = eval { $lh->maketext(@stringified_args) }; |
|
|
0
|
|
|
|
|
|
|
|
57
|
0
|
0
|
|
|
|
|
if ($@) { |
|
58
|
0
|
|
|
|
|
|
warn $@; |
|
59
|
|
|
|
|
|
|
# Sometimes Locale::Maketext fails to localize a string and throws |
|
60
|
|
|
|
|
|
|
# an exception instead. In that case, we just return the input. |
|
61
|
0
|
|
|
|
|
|
return join(' ', @stringified_args); |
|
62
|
|
|
|
|
|
|
} |
|
63
|
0
|
|
|
|
|
|
return $result; |
|
64
|
0
|
|
|
|
|
|
}; |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
{ |
|
67
|
1
|
|
|
1
|
|
5
|
no strict 'refs'; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
40
|
|
|
|
0
|
|
|
|
|
|
|
|
68
|
1
|
|
|
1
|
|
7
|
no warnings 'redefine'; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
217
|
|
|
69
|
|
|
|
|
|
|
#die "I know you!"; |
|
70
|
0
|
|
|
|
|
|
*_ = $loc_method; |
|
71
|
0
|
|
|
|
|
|
${"main::_"} = $loc_method; |
|
|
0
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
} |
|
73
|
0
|
|
|
|
|
|
return $self; |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub _get_file_patterns { |
|
77
|
0
|
|
|
0
|
|
|
my @ret; |
|
78
|
|
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
|
my $dir = File::Spec->rel2abs('po'); |
|
80
|
0
|
0
|
|
|
|
|
if (!-d $dir) { |
|
81
|
0
|
|
|
|
|
|
die "Po Directory po/ does not exist: $dir"; |
|
82
|
|
|
|
|
|
|
} |
|
83
|
0
|
|
|
|
|
|
@ret = "$dir/*.po"; |
|
84
|
0
|
0
|
|
|
|
|
if (!@ret) { |
|
85
|
0
|
|
|
|
|
|
warn "No po/*.po files found.\n"; |
|
86
|
|
|
|
|
|
|
} |
|
87
|
|
|
|
|
|
|
#die "@ret"; |
|
88
|
0
|
|
|
|
|
|
return @ret; |
|
89
|
|
|
|
|
|
|
} |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
package XUL::App::I18N::en; |
|
92
|
1
|
|
|
1
|
|
8
|
use base 'Locale::Maketext'; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
157
|
|
|
93
|
|
|
|
|
|
|
our %Lexicon = ( _fallback => 1, _AUTO => 1 ); |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
1; |
|
96
|
|
|
|
|
|
|
|