Support <option> in template stuff.
[ccbs] / intl / Sesse::GettextizeTemplates.pm
1
2 package Sesse::GettextizeTemplates;
3 use strict;
4 use warnings;
5 use Locale::gettext;
6 use Template::Directive;
7
8 our @ISA = qw(Template::Directive);
9
10 # blah!
11 sub mygettext {
12         my $text = shift;
13
14         return "" if ($text eq "");
15         return Locale::gettext::gettext($text);
16 }
17
18 sub textblock {
19         my ($self, $text) = @_;
20
21         $text =~ s/(<(h[1-6]|p|td|th|title|input|span|li|option|_)[^>]*>)(.*?)(<\/\2>)/$1.mygettext($3).$4/seg;
22         $text =~ s/<\/?_>//g;
23
24         return $self->SUPER::textblock($text);
25 }
26
27
28