KiviLatex-Plugin: HTML-zu-LaTeX-Wandlung aus SL::Template::LaTeX verwenden
[kivitendo-erp.git] / SL / Template / Plugin / T8.pm
index e736e0c..aff4401 100644 (file)
@@ -1,16 +1,19 @@
 package SL::Template::Plugin::T8;
 
-use Template::Plugin::Filter;
-use base qw( Template::Plugin::Filter );
+use strict;
+use parent qw( Template::Plugin::Filter );
 
-my $locale = undef;
+my $cached_instance;
+
+sub new {
+  my $class = shift;
+
+  return $cached_instance ||= $class->SUPER::new(@_);
+}
 
 sub init {
   my $self = shift;
 
-  $locale ||= Locale->new($main::myconfig{countrycode}, 'all');
-
-  # first arg can specify filter name
   $self->install_filter($self->{ _ARGS }->[0] || 'T8');
 
   return $self;
@@ -18,7 +21,7 @@ sub init {
 
 sub filter {
   my ($self, $text, $args) = @_;
-  return $locale->text($text, @{ $args || [] }) || $text;
+  return $::locale->text($text, @{ $args || [] }) || $text;
 }
 
 return 'SL::Template::Plugin::T8';