line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::I18N::Command::Parse; |
2
|
1
|
|
|
1
|
|
2964
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
44
|
|
3
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
34
|
|
4
|
1
|
|
|
1
|
|
7
|
use Cwd; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
80
|
|
5
|
1
|
|
|
1
|
|
604
|
use App::I18N::Config; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
30
|
|
6
|
1
|
|
|
1
|
|
7
|
use App::I18N::Logger; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
24
|
|
7
|
1
|
|
|
1
|
|
5
|
use File::Basename; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
161
|
|
8
|
1
|
|
|
1
|
|
7
|
use File::Path qw(mkpath); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
53
|
|
9
|
1
|
|
|
1
|
|
5
|
use File::Find::Rule; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
13
|
|
10
|
1
|
|
|
1
|
|
45
|
use Locale::Maketext::Extract; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
28
|
|
11
|
1
|
|
|
1
|
|
5
|
use base qw(App::I18N::Command); |
|
1
|
|
|
|
|
8
|
|
|
1
|
|
|
|
|
457
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 NAME |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
parse - parse i18n string from files. |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 USAGE |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
parse [options] [path] |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 OPTIONS |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
--lang |
24
|
|
|
|
|
|
|
--locale |
25
|
|
|
|
|
|
|
--podir=[path] |
26
|
|
|
|
|
|
|
--mo |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=cut |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub options { |
31
|
|
|
|
|
|
|
( |
32
|
0
|
|
|
0
|
0
|
|
'q|quiet' => 'quiet', |
33
|
|
|
|
|
|
|
'l|lang=s' => 'language', |
34
|
|
|
|
|
|
|
'locale' => 'locale', # XXX: use locale directory structure |
35
|
|
|
|
|
|
|
'podir=s' => 'podir', |
36
|
|
|
|
|
|
|
'mo' => 'mo', |
37
|
|
|
|
|
|
|
); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
our $LMExtract = App::I18N->lm_extract(); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub print_help_message { |
43
|
|
|
|
|
|
|
# XXX: |
44
|
0
|
|
|
0
|
0
|
|
return; |
45
|
0
|
|
|
|
|
|
print <
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
In your application include the code below: |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
use App::I18N::I18N; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub hello { |
52
|
|
|
|
|
|
|
print _( "Hello %1" , \$world ); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
END |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub run { |
59
|
0
|
|
|
0
|
0
|
|
my ( $self, @args ) = @_; |
60
|
|
|
|
|
|
|
|
61
|
0
|
|
|
|
|
|
my $podir = $self->{podir}; |
62
|
0
|
0
|
|
|
|
|
$podir = App::I18N->guess_podir( $self ) unless $podir; |
63
|
0
|
0
|
|
|
|
|
$self->{mo} = 1 if $self->{locale}; |
64
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
my @dirs = @args; |
66
|
0
|
|
|
|
|
|
App::I18N->extract_messages( @dirs ); |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
# update app.pot catalog |
69
|
0
|
|
|
|
|
|
mkpath [ $podir ]; |
70
|
|
|
|
|
|
|
|
71
|
0
|
|
|
|
|
|
my $pot_name = App::I18N->pot_name; |
72
|
0
|
|
|
|
|
|
App::I18N->update_catalog( File::Spec->catfile( $podir, $pot_name . ".pot") ); |
73
|
|
|
|
|
|
|
|
74
|
0
|
0
|
|
|
|
|
if ( $self->{'language'} ) { |
75
|
|
|
|
|
|
|
# locale structure |
76
|
|
|
|
|
|
|
# locale/{lang}/LC_MESSAGES/{domain}.po |
77
|
|
|
|
|
|
|
# {podir}/{lang}/LC_MESSAGES/{pot_name}.po |
78
|
0
|
0
|
|
|
|
|
if( $self->{locale} ) { |
79
|
0
|
|
|
|
|
|
mkpath [ File::Spec->join( $podir, $self->{language}, "LC_MESSAGES" ) ]; |
80
|
|
|
|
|
|
|
|
81
|
0
|
|
|
|
|
|
my $pofile = File::Spec->catfile( $podir, $self->{language}, "LC_MESSAGES", $pot_name . ".po" ); |
82
|
0
|
|
|
|
|
|
App::I18N->update_catalog( $pofile, $self ); |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
else { |
85
|
0
|
|
|
|
|
|
App::I18N->update_catalog( File::Spec->catfile( $podir, $self->{language} . ".po" ), $self ); |
86
|
|
|
|
|
|
|
} |
87
|
0
|
|
|
|
|
|
return; |
88
|
|
|
|
|
|
|
} |
89
|
0
|
|
|
|
|
|
App::I18N->update_catalogs( $podir , $self ); |
90
|
0
|
|
|
|
|
|
print_help_message(); |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
1; |
94
|
|
|
|
|
|
|
__END__ |