#!/usr/bin/perl -w -s
## use utf8::all;
our ($w,$max,$pdf);
$max //= 200;
$max = 1000000000 if $max == 0;
use strict;
use warnings;
my $p = shift;
$p = qr{\b$p\b} if $w;
use XML::TMX;
use XML::TMX::Reader;
our ($icons);
my $tmx = shift;
my $tmx_obj = XML::TMX::Reader->new($tmx);
$tmx_obj->for_tu(
{ patt => $p,
gen_tu=> $max,
output => "__.tmx" },
sub { my($tu,$at) = @_;
# print STDERR ".";
for(keys %$tu){
$tu->{$_} =~ s!($p)!=($1)=!g;
}
return $tu;
}
);
if($pdf){ system("xpdf-tmx __.tmx");}
__END__
=head1 NAME
tmxgrep - grep translation units in a TMX file
=head1 SYNOPSIS
tmxgrep <perlregexp> file.tmx
options:
-pdf -- output is transformed in a PDF file
-max=300 -- extract up to 300 TU (def=200)
-max=0 -- all matches
=head1 DESCRIPTION
Creates a TMX file with the tranlation units tha macth the provided
regular expression.
=head1 AUTHOR
J.Joao Almeida, jj@di.uminho.pt
=head1 SEE ALSO
perl(1).
xpdf-tmx
XML::TMX
TMX
=cut