a505b6e151218a846a30c946d568dadb75987a4e
[ccbs] / intl / Sesse::ExtractGettext.pm
1
2 package Sesse::ExtractGettext;
3 use strict;
4 use warnings;
5 use Template::Directive;
6
7 our @ISA = qw(Template::Directive);
8
9 sub textblock {
10         my ($self, $text) = @_;
11
12         while ($text =~ s/<(h[1-6]|p|td|th|title|input|span|li|_)[^>]*>(.*?)<\/\1>//s) {
13                 my $id = $2;
14                 next if $id =~ /^\s*$/;
15                 $id =~ s/\n/\\n"\n"/g;
16                 $id =~ s/(.)"(?!\n)/$1\\"/g;
17         
18                 print "msgid \"$id\"\n";
19                 print "msgstr \"\"\n";
20                 print "\n";
21         }
22
23         return $self->SUPER::textblock($text);
24 }
25
26
27