Bugzilla – Attachment 77798 Details for
Bug 19817
Merge local and online documentations
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 19817: Use the language from the interface if valid
Bug-19817-Use-the-language-from-the-interface-if-v.patch (text/plain), 3.80 KB, created by
Martin Renvoize (ashimema)
on 2018-08-14 15:13:36 UTC
(
hide
)
Description:
Bug 19817: Use the language from the interface if valid
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2018-08-14 15:13:36 UTC
Size:
3.80 KB
patch
obsolete
>From af32e7139b48b36a2cf1f20ba395a8ac3b921e04 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Mon, 9 Apr 2018 11:30:01 -0300 >Subject: [PATCH] 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 <martin.renvoize@ptfs-europe.com> >--- > Koha/Manual.pm | 16 +++++++++++++--- > help.pl | 15 ++++++++++++++- > .../admin/preferences/enhanced_content.pref | 1 + > 3 files changed, 28 insertions(+), 4 deletions(-) > >diff --git a/Koha/Manual.pm b/Koha/Manual.pm >index fe0c3a2998..cab6156f95 100644 >--- a/Koha/Manual.pm >+++ b/Koha/Manual.pm >@@ -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} ); > } > >diff --git a/help.pl b/help.pl >index df946491e5..b39c5773f1 100755 >--- a/help.pl >+++ b/help.pl >@@ -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); >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/enhanced_content.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/enhanced_content.pref >index bb6350cdb7..c3e77f2ad7 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/enhanced_content.pref >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/enhanced_content.pref >@@ -417,3 +417,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. >-- >2.18.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 19817
:
69807
|
69808
|
70131
|
70132
|
70133
|
73523
|
73524
|
73525
|
73526
|
73527
|
73651
|
73652
|
73872
|
73877
|
73931
|
73932
|
73933
|
73934
|
73935
|
73936
|
73937
|
73938
|
74567
|
74568
|
74569
|
74570
|
74571
|
74572
|
74573
|
74574
|
74644
|
74645
|
74646
|
74647
|
74648
|
74649
|
74650
|
74651
|
75370
|
75371
|
75372
|
75373
|
75374
|
75375
|
75376
|
75377
|
76151
|
76152
|
76153
|
76154
|
76155
|
76156
|
76157
|
76158
|
77791
|
77792
|
77793
|
77794
|
77795
|
77797
|
77798
|
77799
|
77932
|
77942
|
77943
|
77944
|
77945
|
77946
|
77947
|
77948
|
77949
|
77950
|
77951
|
78953
|
87238