-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck_translations.pl
60 lines (44 loc) · 1.41 KB
/
check_translations.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
use strict;
use warnings;
use File::Spec ();
foreach my $plugin_dir ( glob("Padre-Plugin-*") ) {
my $locale = File::Spec->catdir( $plugin_dir, 'share', 'locale' );
if ( -d $locale ) {
( my $plugin_name = $plugin_dir ) =~ s/Padre-Plugin-(\w+)/$1/;
foreach my $pofile ( glob( File::Spec->catfile( $locale, '*.po' ) ) ) {
if ( $pofile =~ /Padre__Plugin__$plugin_name-(.+?)\.po/ ) {
if ( open( my $fh, $pofile ) ) {
while ( my $line = <$fh> ) {
if ( $line =~ /^"Project-Id-Version:\s+(.+?)\\n"/ ) {
my $project_id_version = $1;
if ( $project_id_version ne $plugin_dir ) {
print "Project-Id-Version Mismatch at $pofile\n";
}
last;
}
}
close $fh;
} else {
print "Could not open $pofile for reading\n";
}
} else {
print "Found mismatched filename $pofile\n";
}
}
}
}
__END__
=head1 NAME
check_translations - Checks Padre plugin translations for problems
=head1 DESCRIPTION
Checks Padre plugin translations for the following:
=over 4
=item * A PO file must have the format Padre__Plugin__PluginName.po
=item * "Project-Id-Version" should be the same as the Plugin project dir
=back
=head1 AUTHOR
Ahmad M. Zawawi C<< <ahmad.zawawi at gmail.com> >>
=head1 COPYRIGHT AND LICENSE
Copyright 2010 C<< <ahmad.zawawi at gmail.com> >>
This program is free software; you can redistribute it and/or
modify it under the same terms as Perl 5 itself.