]> git.sesse.net Git - ttk-gettext/blobdiff - Sesse::ExtractGettext.pm
Add all the files.
[ttk-gettext] / Sesse::ExtractGettext.pm
diff --git a/Sesse::ExtractGettext.pm b/Sesse::ExtractGettext.pm
new file mode 100644 (file)
index 0000000..734962f
--- /dev/null
@@ -0,0 +1,27 @@
+
+package Sesse::ExtractGettext;
+use strict;
+use warnings;
+use Template::Directive;
+
+our @ISA = qw(Template::Directive);
+
+sub textblock {
+       my ($self, $text) = @_;
+
+       while ($text =~ s/<(h[1-6]|p|td|th|title|input|span|li|option|_)[^>]*>(.*?)<\/\1>//s) {
+               my $id = $2;
+               next if $id =~ /^\s*$/;
+               $id =~ s/\n/\\n"\n"/g;
+               $id =~ s/(.)"(?!\n)/$1\\"/g;
+       
+               print "msgid \"$id\"\n";
+               print "msgstr \"\"\n";
+               print "\n";
+       }
+
+       return $self->SUPER::textblock($text);
+}
+
+
+