X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FLocale.pm;h=a6756fefeae0d3024ffb68ca6d1521aef13f8e1b;hb=a4f92ff17d2572ec3a0465fe4444c741d80ecc77;hp=8e7037d789b909609340b9976e29b245ac6a3c57;hpb=541272c5cf4f874a13eff89993d5d4a941451f42;p=kivitendo-erp.git diff --git a/SL/Locale.pm b/SL/Locale.pm index 8e7037d78..a6756fefe 100644 --- a/SL/Locale.pm +++ b/SL/Locale.pm @@ -36,7 +36,10 @@ package Locale; +use Text::Iconv; + use SL::LXDebug; +use SL::Common; sub new { $main::lxdebug->enter_sub(); @@ -44,14 +47,33 @@ 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("", ); eval($code); close(IN); } + + if (open IN, "<", "locale/$country/charset") { + $self->{charset} = ; + close IN; + + chomp $self->{charset}; + + } else { + $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); } $self->{NLS_file} = $NLS_file; @@ -71,7 +93,11 @@ sub new { sub text { my ($self, $text) = @_; - return (exists $self->{texts}{$text}) ? $self->{texts}{$text} : $text; + if (exists $self->{texts}->{$text}) { + return $self->{iconv}->convert($self->{texts}->{$text}); + } + + return $self->{iconv_english}->convert($text); } sub findsub {