From 314435881739d2a0a54dcdc25fa283e134555c28 Mon Sep 17 00:00:00 2001 From: rangi Date: Wed, 27 Jun 2001 21:53:05 +0000 Subject: [PATCH] Modified so that the first available language is chosen if none is specified --- translator/translator.pl | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/translator/translator.pl b/translator/translator.pl index 3fe4632b3f..e1bbe2f5ef 100755 --- a/translator/translator.pl +++ b/translator/translator.pl @@ -20,25 +20,32 @@ my $path=$ENV{"PATH_TRANSLATED"}; textdomain("koha"); -my %lang=( - fr => "fr_FR", - pl => "pl_PL", -); +my @locale=`locale -a`; +my %lang; +foreach(@locale){ + next unless (/_/); + push @{$lang{$`}}, $'; +} -my @lang=split/,/,$ENV{"HTTP_ACCEPT_LANGUAGE"}; +my $str_env=$ENV{"HTTP_ACCEPT_LANGUAGE"}; +$str_env=~s/\s*//g; +my @lang=split/,/,$str_env; my $lang="us_US"; -foreach (@lang){ - my $lg=$lang{$_}; - setlocale(LC_MESSAGES,$lg); - my $tmp = gettext($_); - if ($tmp ne $_) - { - $lang=$tmp; - last; +foreach my $locale(@lang){ + goto find_locale if ($locale eq 'en'); + foreach my $lg(@{$lang{$locale}}){ + setlocale(LC_MESSAGES,$locale."_".$lg); + my $tmp = gettext($locale); + if ($tmp ne $locale) + { + $lang=$tmp; + goto find_locale; + } } } +find_locale: setlocale(LC_MESSAGES,$lang); my @katalog; @@ -62,6 +69,8 @@ my (%dgettxt, %dane, %dane2, @dane2); my $i; $dgettxt{'iso-8859-1'}=1; +$dgettxt{'us_US'}=1; + my $txt =<