line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::I18N::Command::Lang; |
2
|
1
|
|
|
1
|
|
1641
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
44
|
|
3
|
1
|
|
|
1
|
|
8
|
use strict; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
34
|
|
4
|
1
|
|
|
1
|
|
6
|
use Cwd; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
89
|
|
5
|
1
|
|
|
1
|
|
6
|
use App::I18N::Config; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
21
|
|
6
|
1
|
|
|
1
|
|
5
|
use App::I18N::Logger; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
26
|
|
7
|
1
|
|
|
1
|
|
5
|
use File::Basename; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
78
|
|
8
|
1
|
|
|
1
|
|
18
|
use File::Path qw(mkpath); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
60
|
|
9
|
1
|
|
|
1
|
|
6
|
use File::Find::Rule; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
12
|
|
10
|
1
|
|
|
1
|
|
64
|
use base qw(App::I18N::Command); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
149
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 NAME |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Lang - create new langauge |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 USAGE |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
--mo generate mo file |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
--locale create new po file from pot file in locale directory structure: |
22
|
|
|
|
|
|
|
{podir}/{lang}/LC_MESSAGES/{potname}.po |
23
|
|
|
|
|
|
|
this will enable --mo option |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
-q |
27
|
|
|
|
|
|
|
--quiet just be quiet |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
--podir=[path] |
30
|
|
|
|
|
|
|
po directory. potfile will be generated in {podir}/{appname}.pot |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=cut |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub options { ( |
35
|
0
|
|
|
0
|
0
|
|
'q|quiet' => 'quiet', |
36
|
|
|
|
|
|
|
'locale' => 'locale', |
37
|
|
|
|
|
|
|
'mo' => 'mo', # generate mo file |
38
|
|
|
|
|
|
|
'podir=s' => 'podir', |
39
|
|
|
|
|
|
|
) } |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub copy_potfile { |
43
|
0
|
|
|
0
|
0
|
|
my ( $self, $potfile, $pofile ) = @_; |
44
|
1
|
|
|
1
|
|
7
|
use File::Copy; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
591
|
|
45
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
$self->logger->info( "$pofile created."); |
47
|
0
|
|
|
|
|
|
copy( $potfile , $pofile ); |
48
|
0
|
0
|
|
|
|
|
if( $self->{mo} ) { |
49
|
0
|
|
|
|
|
|
my $mofile = $pofile; |
50
|
0
|
|
|
|
|
|
$mofile =~ s{\.po$}{.mo}; |
51
|
0
|
|
|
|
|
|
$self->logger->info( "Generating MO file: $mofile" ); |
52
|
0
|
|
|
|
|
|
system(qq{msgfmt -v $pofile -o $mofile}); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub run { |
57
|
0
|
|
|
0
|
0
|
|
my ( $self, @langs ) = @_; |
58
|
0
|
|
|
|
|
|
my $logger = $self->logger(); |
59
|
|
|
|
|
|
|
|
60
|
0
|
|
|
|
|
|
my $podir = $self->{podir}; |
61
|
0
|
0
|
|
|
|
|
$podir = App::I18N->guess_podir( $self ) unless $podir; |
62
|
0
|
0
|
|
|
|
|
$self->{mo} = 1 if $self->{locale}; |
63
|
|
|
|
|
|
|
|
64
|
0
|
|
|
|
|
|
mkpath [ $podir ]; |
65
|
|
|
|
|
|
|
|
66
|
0
|
|
|
|
|
|
my $pot_name = App::I18N->pot_name; |
67
|
|
|
|
|
|
|
|
68
|
0
|
|
|
|
|
|
my $potfile = File::Spec->catfile( $podir, $pot_name . ".pot") ; |
69
|
0
|
0
|
|
|
|
|
if( ! -e $potfile ) { |
70
|
0
|
|
|
|
|
|
$logger->info( "$potfile not found." ); |
71
|
0
|
|
|
|
|
|
return; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
0
|
|
|
|
|
|
$logger->info( "$potfile found." ); |
75
|
0
|
|
|
|
|
|
my $pofile; |
76
|
0
|
0
|
|
|
|
|
if( $self->{locale} ) { |
77
|
0
|
|
|
|
|
|
for my $lang ( @langs ) { |
78
|
0
|
|
|
|
|
|
mkpath [ File::Spec->join( $podir , $lang , 'LC_MESSAGES' ) ]; |
79
|
0
|
|
|
|
|
|
$pofile = File::Spec->join( $podir , $lang , 'LC_MESSAGES' , $pot_name . ".po" ); |
80
|
0
|
|
|
|
|
|
$self->copy_potfile( $potfile , $pofile ); |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
else { |
84
|
0
|
|
|
|
|
|
for my $lang ( @langs ) { |
85
|
0
|
|
|
|
|
|
$pofile = File::Spec->join( $podir , $lang . ".po" ); |
86
|
0
|
|
|
|
|
|
$self->copy_potfile( $potfile , $pofile ); |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
} |
89
|
0
|
|
|
|
|
|
$logger->info( "Done" ); |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
1; |