Bug 14045: DBRev 3.21.00.035
[koha.git] / misc / translator / text-extract.pl
blob4e2fbdce779bae9b817f7289bc28a37d42a11b25
1 #!/usr/bin/perl
2 #use strict;
3 #use warnings; FIXME - Bug 2505
4 use HTML::Tree;
5 use Getopt::Std;
6 getopt("f:");
7 my $tree = HTML::TreeBuilder->new; # empty tree
9 $tree->parse_file($opt_f);
10 sub give_id {
11 my $x = $_[0];
12 foreach my $c ($x->content_list) {
13 next if (ref($c) && $c->tag() eq "~comment");
14 next if (ref($c) && $c->tag() eq "script");
15 next if (ref($c) && $c->tag() eq "style");
16 if (!ref($c)) {
17 print "$c\n";
19 if (ref($c) && $c->attr('alt')) {
20 print $c->attr('alt')."\n";
22 if (ref($c) && $c->attr('title')) {
23 print $c->attr('title')."\n";
25 if (ref($c) && $c->tag() eq "input" && $c->attr('value')) {
26 print $c->attr('value')."\n";
28 if (ref($c) && $c->tag() eq 'meta') {
29 print $c->attr('content')."\n ";
31 give_id($c) if ref $c; # ignore text nodes
34 give_id($tree);
35 $tree = $tree->delete;