Commit bfbc6cc9 authored by joubu's avatar joubu Committed by Wm. Nick Clemens

Bug 19817: Use the language from the interface if valid

Use the UI language for the manual, if exists. Use the pref as a
fallback.

With the call to get_template_and_user the value of preferred_language
switched from 'es' (spanish) to 'en' from one click to another (??)
Signed-off-by: Martin Renvoize's avatarMartin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Katrin Fischer's avatarKatrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Wm. Nick Clemens's avatarNick Clemens <nick@bywatersolutions.com>
parent ac07a507
......@@ -17,8 +17,18 @@ sub _get_help_version {
}
sub _get_base_url {
my ( $preferred_language ) = @_;
my @available_languages = qw( en ar cs es fr it pt_BZ tz zh_TW );
my ( $language ) = grep {
my $preferred_short = substr $preferred_language, 0, 2;
my $avail_short = substr $_, 0, 2;
$preferred_short eq $avail_short ? $_ : ()
} @available_languages;
my $KohaManualLanguage = $language || C4::Context->preference('KohaManualLanguage') || 'en';
my $KohaManualBaseURL = C4::Context->preference('KohaManualBaseURL') || 'http://koha-community.org/manual';
my $KohaManualLanguage = C4::Context->preference('KohaManualLanguage') || 'en';
if ( $KohaManualBaseURL =~ m|^/| ) {
$KohaManualBaseURL = C4::Context->preference('staffClientBaseURL') . $KohaManualBaseURL;
}
......@@ -221,7 +231,7 @@ our $mapping = {
};
sub get_url {
my $url = shift;
my ( $url, $preferred_language ) = @_;
my $file;
if ($url =~ /koha\/(.*)\.pl/) {
$file = $1;
......@@ -230,7 +240,7 @@ sub get_url {
}
$file =~ s/[^a-zA-Z0-9_\-\/]*//g;
my $base_url = _get_base_url;
my $base_url = _get_base_url( $preferred_language );
return $base_url . ( exists $mapping->{$file} ? $mapping->{$file} : $mapping->{mainpage} );
}
......
......@@ -20,15 +20,28 @@
use Modern::Perl;
use CGI qw ( -utf8 );
use C4::Auth;
use C4::Context;
use Koha::Manual;
my $query = new CGI;
# We need to call get_template_and_user to let it does the job correctly
# for the language
my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user(
{
template_name => "intranet-main.tt", # Just a valid template path
query => $query,
type => "intranet",
authnotrequired => 1,
}
);
# find the script that called the online help using the CGI referer()
our $refer = $query->param('url');
$refer = $query->referer() if !$refer || $refer eq 'undefined';
my $manual_url = Koha::Manual::get_url($refer);
my $language = C4::Languages::getlanguage( $query );
my $manual_url = Koha::Manual::get_url($refer, $language);
print $query->redirect($manual_url);
......@@ -401,3 +401,4 @@ Enhanced Content:
pt_BR: Portuguese – Brazil
tr: Turkish
zh_TW: Chinese – Taiwan
- It will be used as a fallback value if the language used by the interface does not have an online manual version.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment