]> git.sesse.net Git - ccbs/blob - intl/Sesse::ExtractGettext.pm
Shape text using Pango and HarfBuzz; gives us nice ligatures and exotic scripts.
[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|option|_)[^>]*>(.*?)<\/\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