build: adapt i18n-update.pl to new structure

Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
This commit is contained in:
Jo-Philipp Wich 2015-01-08 16:46:58 +01:00
parent 85e4256a7a
commit fe9ef86750

View file

@ -1,6 +1,6 @@
#!/usr/bin/perl #!/usr/bin/perl
@ARGV >= 1 || die "Usage: $0 <po directory> [<file pattern>]\n"; @ARGV <= 2 || die "Usage: $0 [<po directory>] [<file pattern>]\n";
my $source = shift @ARGV; my $source = shift @ARGV;
my $pattern = shift @ARGV || '*.po'; my $pattern = shift @ARGV || '*.po';
@ -48,18 +48,31 @@ sub write_header
close P; close P;
} }
if( open F, "find $source -type f -name '$pattern' |" ) my @dirs;
if( ! $source )
{
@dirs = glob("./*/*/po/");
}
else
{
@dirs = ( $source );
}
foreach my $dir (@dirs)
{
if( open F, "find $dir -type f -name '$pattern' |" )
{ {
while( chomp( my $file = readline F ) ) while( chomp( my $file = readline F ) )
{ {
my ( $basename ) = $file =~ m{.+/([^/]+)\.po$}; my ( $basename ) = $file =~ m{.+/([^/]+)\.po$};
if( -f "$source/templates/$basename.pot" ) if( -f "$dir/templates/$basename.pot" )
{ {
my $head = read_header($file); my $head = read_header($file);
printf "Updating %-40s", $file; printf "Updating %-40s", $file;
system("msgmerge", "-U", "-N", $file, "$source/templates/$basename.pot"); system("msgmerge", "-U", "-N", $file, "$dir/templates/$basename.pot");
write_header($file, $head); write_header($file, $head);
} }
@ -67,3 +80,4 @@ if( open F, "find $source -type f -name '$pattern' |" )
close F; close F;
} }
}