Adding a few new languages and more updates
[koha.git] / misc / translator / text-extract.pl
1 #!/usr/bin/perl
2 use HTML::Tree;
3 use Getopt::Std;
4 getopt("f:");
5         my $tree = HTML::TreeBuilder->new; # empty tree
6
7         $tree->parse_file($opt_f);
8         sub give_id {
9                 my $x = $_[0];
10                 foreach my $c ($x->content_list) {
11                         next if (ref($c) && $c->tag() eq "~comment");
12                         next if (ref($c) && $c->tag() eq "script");
13                         next if (ref($c) && $c->tag() eq "style");
14                         if (!ref($c)) {
15                                 print "$c\n";
16                         }
17                         if (ref($c) && $c->attr('alt')) {
18                                 print $c->attr('alt')."\n";
19                         }
20                         if (ref($c) && $c->attr('title')) {
21                                 print $c->attr('title')."\n";
22                         }
23                         if (ref($c) && $c->tag() eq "input" && $c->attr('value')) {
24                                 print $c->attr('value')."\n";
25                         }
26                         if (ref($c) && $c->tag() eq 'meta') {
27                                 print $c->attr('content')."\n ";
28                         }
29                         give_id($c) if ref $c; # ignore text nodes
30                 }
31         };
32         give_id($tree);
33         $tree = $tree->delete;