From 8246a7dce86ec220f0c1cabf25a0d815ff439624 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fr=C3=A9d=C3=A9ric=20Demians?= Date: Thu, 30 Apr 2009 17:23:17 +0200 Subject: [PATCH] Bugfix 3176 - Browser selected languages are not use by OPAC This patch uses HTTP_ACCEPT_LANGUAGE web browser variable to select OPAC available language. Signed-off-by: Galen Charlton --- C4/Languages.pm | 10 +++++----- C4/Output.pm | 11 ++++------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/C4/Languages.pm b/C4/Languages.pm index 5795202a7e..a082b1f8b5 100644 --- a/C4/Languages.pm +++ b/C4/Languages.pm @@ -443,7 +443,6 @@ sub accept_language { if ($clientPreferences) { # There should be no whitespace anways, but a cleanliness/sanity check $clientPreferences =~ s/\s//g; - # Prepare the list of client-acceptable languages foreach my $tag (split(/,/, $clientPreferences)) { my ($language, $quality) = split(/\;/, $tag); @@ -464,10 +463,11 @@ sub accept_language { my %supportedLanguages = (); my %secondaryLanguages = (); foreach my $language (@$supportedLanguages) { - # warn "Language supported: " . $language->{language_code}; - $supportedLanguages{lc($language->{language_code})} = $language->{language_code}; - if ($language->{language_code} =~ /^([^-]+)-?/) { - $secondaryLanguages{lc($1)} = $language->{language_code}; + # warn "Language supported: " . $language->{language}; + my $subtag = $language->{rfc4646_subtag}; + $supportedLanguages{lc($subtag)} = $subtag; + if ( $subtag =~ /^([^-]+)-?/ ) { + $secondaryLanguages{lc($1)} = $subtag; } } diff --git a/C4/Output.pm b/C4/Output.pm index c8404dc05b..36b83a2904 100644 --- a/C4/Output.pm +++ b/C4/Output.pm @@ -139,13 +139,10 @@ sub themelanguage { # Set some defaults for language and theme # First, check the user's preferences my $lang; - my $http_env = $ENV{HTTP_ACCEPT_LANGUAGE}; - $http_env =~ m/(\w+-*\w*),/; - my $language_preference = $1; - my $http_accept_language = regex_lang_subtags($language_preference)->{language}; - if ($http_accept_language) { - $lang = accept_language($http_accept_language,getTranslatedLanguages($interface,'prog')); - } + my $http_accept_language = $ENV{ HTTP_ACCEPT_LANGUAGE }; + $lang = accept_language( $http_accept_language, + getTranslatedLanguages($interface,'prog') ) + if $http_accept_language; # But, if there's a cookie set, obey it $lang = $query->cookie('KohaOpacLanguage') if $query->cookie('KohaOpacLanguage'); # Fall back to English -- 2.39.5