X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/e09e900d226835ec8d8983e0df5861157bcb2897..0b34e29fb04ad9ac9912f67b767f9f401700ca97:/SL/Locale.pm diff --git a/SL/Locale.pm b/SL/Locale.pm index 8495553e8..f568b0826 100644 --- a/SL/Locale.pm +++ b/SL/Locale.pm @@ -45,47 +45,64 @@ use SL::LXDebug; use SL::Common; use SL::Iconv; use SL::Inifile; +use XML::LibXML; use strict; -my %locales_by_country; +my %locales_by_language; sub new { $main::lxdebug->enter_sub(); - my ($type, $country) = @_; + my ($type, $language) = @_; - $country ||= $::lx_office_conf{system}->{language}; - $country =~ s|.*/||; - $country =~ s|\.||g; + $language ||= $::lx_office_conf{system}->{language}; + $language =~ s|.*/||; + $language =~ s|\.||g; - if (!$locales_by_country{$country}) { + if (!$locales_by_language{$language}) { my $self = {}; bless $self, $type; - $self->_init($country); + $self->_init($language); - $locales_by_country{$country} = $self; + $locales_by_language{$language} = $self; } $main::lxdebug->leave_sub(); - return $locales_by_country{$country} + return $locales_by_language{$language} } sub _init { my $self = shift; - my $country = shift; + my $language = shift; - $self->{countrycode} = $country; + $self->{countrycode} = $language; - if ($country && -d "locale/$country") { + if ($language && -d "locale/$language") { local *IN; - if (open(IN, "<", "locale/$country/all")) { + if (open(IN, "<", "locale/$language/all")) { my $code = join("", ); eval($code); close(IN); } + + if (-d "locale/$language/more") { + opendir my $dh, "locale/$language/more" or die "can't open locale/$language/more: $!"; + my @files = sort grep -f "locale/$language/more/$_", readdir $dh; + close $dh; + + for my $file (@files) { + if (open my $in, "<", "locale/$language/more/$file") { + local $/ = undef; + my $code = <$in>; + eval($code); + close($in); + $self->{texts}{$_} = $self->{more_texts}{$_} for keys %{ $self->{more_texts} }; + } + } + } } binmode STDOUT, ":utf8"; @@ -98,7 +115,7 @@ sub _init { $self->{iconv_to_iso8859} = SL::Iconv->new('UTF-8', 'ISO-8859-15'); $self->{iconv_utf8} = SL::Iconv->new('UTF-8', 'UTF-8'); - $self->_read_special_chars_file($country); + $self->_read_special_chars_file($language); push @{ $self->{LONG_MONTH} }, ("January", "February", "March", "April", @@ -151,14 +168,14 @@ sub _handle_markup { sub _read_special_chars_file { my $self = shift; - my $country = shift; + my $language = shift; - if (! -f "locale/$country/special_chars") { + if (! -f "locale/$language/special_chars") { $self->{special_chars_map} = {}; return; } - $self->{special_chars_map} = Inifile->new("locale/$country/special_chars", 'verbatim' => 1); + $self->{special_chars_map} = Inifile->new("locale/$language/special_chars", 'verbatim' => 1); foreach my $format (keys %{ $self->{special_chars_map} }) { next if (($format eq 'FILE') || ($format eq 'ORDER') || (ref $self->{special_chars_map}->{$format} ne 'HASH'));