Eine Hilfsfunktion, die aus Array- und Hashstrukturen in $form eine Liste von Variabl...
[kivitendo-erp.git] / SL / Locale.pm
index e941f00..f797ed6 100644 (file)
@@ -47,10 +47,14 @@ sub new {
   my ($type, $country, $NLS_file) = @_;
   my $self = {};
 
+  $country  =~ s|.*/||;
+  $country  =~ s|\.||g;
+  $NLS_file =~ s|.*/||;
+
   if ($country && -d "locale/$country") {
     local *IN;
     $self->{countrycode} = $country;
-    if (open(IN, "locale/$country/$NLS_file")) {
+    if (open(IN, "<", "locale/$country/$NLS_file")) {
       my $code = join("", <IN>);
       eval($code);
       close(IN);
@@ -66,10 +70,11 @@ sub new {
       $self->{charset} = Common::DEFAULT_CHARSET;
     }
 
-    my $db_charset = $main::dbcharset;
-    $db_charset ||= Common::DEFAULT_CHARSET;
-    $self->{iconv} = Text::Iconv->new($self->{charset}, $db_charset);
-    $self->{iconv_english} = Text::Iconv->new("ASCII", $db_charset);
+    my $db_charset         = $main::dbcharset || Common::DEFAULT_CHARSET;
+
+    $self->{iconv}         = Text::Iconv->new($self->{charset}, $db_charset);
+    $self->{iconv_english} = Text::Iconv->new('ASCII',          $db_charset);
+    $self->{iconv_iso8859} = Text::Iconv->new('ISO-8859-15',    $db_charset);
   }
 
   $self->{NLS_file} = $NLS_file;
@@ -87,13 +92,20 @@ sub new {
 }
 
 sub text {
-  my ($self, $text) = @_;
+  my $self = shift;
+  my $text = shift;
 
   if (exists $self->{texts}->{$text}) {
-    return $self->{iconv}->convert($self->{texts}->{$text});
+    $text = $self->{iconv}->convert($self->{texts}->{$text});
+  } else {
+    $text = $self->{iconv_english}->convert($text);
   }
 
-  return $self->{iconv_english}->convert($text);
+  if (@_) {
+    $text = Form->format_string($text, @_);
+  }
+
+  return $text;
 }
 
 sub findsub {