#! /usr/bin/perl
use strict;
use warnings;
use POSIX;
use Locale::gettext;
use Template;
require 'Sesse::GettextizeTemplates.pm';

# Common short macro to get non-templatized gettext stuff working
*_ = sub {
	return Locale::gettext::gettext(@_);
};

# set the locale
POSIX::setlocale(&POSIX::LC_CTYPE, "");
POSIX::setlocale(&POSIX::LC_MESSAGES, "");
Locale::gettext::bindtextdomain("myproject", ".");
Locale::gettext::textdomain("myproject");

# Do a test message with no templates
print _("Test message from outside a template.\n");

# Process the test template and print it to stdout
my $template = Template->new({ FACTORY => 'Sesse::GettextizeTemplates' });
my $output = '';
$template->process('test.tmpl', { foo => int(rand 2) }, \$output)
	or die $template->error();

print $output;
