Skip to content

Commit

Permalink
Fix PDF translation by switching the locale with [setlocale].
Browse files Browse the repository at this point in the history
  • Loading branch information
racke committed Feb 8, 2011
1 parent dd7710e commit 295c0fd
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions lib/Vend/PDF.pm
Expand Up @@ -39,7 +39,7 @@ Vend::Config::parse_tag('UserTag', 'pdf MapRoutine Vend::PDF::pdf');
# [pdf]
sub pdf {
my ($specification, $template, $output, $opt) = @_;
my (%input);
my (%input, $locale);

# input for Zoom template
if (exists $opt->{input}) {
Expand All @@ -59,12 +59,20 @@ sub pdf {
my ($i18n, $sub);

if ($opt->{locale}) {
$locale = Vend::Tags->setlocale({get => 1});

Vend::Tags->setlocale($opt->{locale});

$sub = sub {
my $text = shift;
my $out;

return Vend::Tags->filter({op => "loc.$opt->{locale}", body => $text});
$out = ::errmsg($text);

return $out;

};

$i18n = new Template::Zoom::I18N ($sub);

}
Expand Down Expand Up @@ -116,6 +124,10 @@ sub pdf {

$pdf->process($output);

if ($opt->{locale}) {
Vend::Tags->setlocale($locale);
}

return;
}

Expand Down

0 comments on commit 295c0fd

Please sign in to comment.