
package Sesse::GettextizeTemplates;
use strict;
use warnings;
use Locale::gettext;
use Template::Directive;

our @ISA = qw(Template::Directive);

# blah!
sub mygettext {
	my $text = shift;

	return "" if ($text eq "");
	return Locale::gettext::gettext($text);
}

sub textblock {
	my ($self, $text) = @_;

	$text =~ s/(<(h[1-6]|p|td|th|title|input|span|li|option|_)[^>]*>)(.*?)(<\/\2>)/$1.mygettext($3).$4/seg;
	$text =~ s/<\/?_>//g;

	return $self->SUPER::textblock($text);
}



