Bug 30958 - OPAC Overdrive search result page broken for translations
Summary: OPAC Overdrive search result page broken for translations
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: I18N/L10N (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal
Assignee: Alex Buckley
QA Contact: Katrin Fischer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-06-13 22:38 UTC by Alex Buckley
Modified: 2023-06-08 22:26 UTC (History)
4 users (show)

See Also:
Change sponsored?: Sponsored
Patch complexity: Trivial patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
22.11.00, 22.05.03, 21.11.11, 21.05.18
Circulation function:


Attachments
Bug 30958: OPAC overdrive search result page broken for translations (2.30 KB, patch)
2022-06-13 23:26 UTC, Alex Buckley
Details | Diff | Splinter Review
Bug 30958: OPAC overdrive search result page broken for translations (2.37 KB, patch)
2022-06-14 12:02 UTC, Owen Leonard
Details | Diff | Splinter Review
Bug 30958: OPAC overdrive search result page broken for translations (2.43 KB, patch)
2022-06-17 20:52 UTC, Katrin Fischer
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Buckley 2022-06-13 22:38:26 UTC
If a library does not have the OverDrivePasswordRequired system preference = 'Required' then translated OPAC Overdrive search result pages throw a JavaScript error and do not display results.

The problematic line (below) in the English template is:
var OD_password_required = [% IF Koha.Preference('OverDrivePasswordRequired') %]1[% ELSE %]0[% END %];

Which is translated to the following in the en-NZ (and other languages) template:
var OD_password_required = [% IF Koha.Preference('OverDrivePasswordRequired') %]1[% ELSE %][% END %];

Like in bug 23713 the line is translated to:
var OD_password_required = ;

When it should be:
var OD_password_required = 0;
Comment 1 Alex Buckley 2022-06-13 23:26:46 UTC
Created attachment 136056 [details] [review]
Bug 30958: OPAC overdrive search result page broken for translations

Note: You will need a valid OverDrive subscription to test this.

This patch fixes a JavaScript error thrown on the OPAC overdrive search
results page for libraries using translation templates and who don't
have the OverDrivePasswordRequired system preference = 'Required'.

Test plan:
1. Install the en-NZ translation: https://wiki.koha-community.org/wiki/Installation_of_additional_languages_for_OPAC_and_INTRANET_staff_client

2. Enable the en-NZ language:
- In the OPACLanguages system preference -> tick 'English New Zealand (en-NZ)' checkbox and
untick 'English (en)'

3. Fill in the OverDrive system preferences:
- Make sure you set: OverDrivePasswordRequired = "Not required"

4. Perform an OPAC search

5. Click on the Overdrive results link

6. Open the browser console and notice there is a JS error, and the
OverDrive results do not load

7. Apply patch

8. Update the en_NZ translation:

9. Repeat steps 4, 5 and 6 and notice there is no JavaScript error and
the OverDrive results do display

Sponsored-by: Melbourne Athenaeum Library, Australia
Comment 2 Owen Leonard 2022-06-14 12:02:03 UTC
Created attachment 136068 [details] [review]
Bug 30958: OPAC overdrive search result page broken for translations

Note: You will need a valid OverDrive subscription to test this.

This patch fixes a JavaScript error thrown on the OPAC overdrive search
results page for libraries using translation templates and who don't
have the OverDrivePasswordRequired system preference = 'Required'.

Test plan:
1. Install the en-NZ translation: https://wiki.koha-community.org/wiki/Installation_of_additional_languages_for_OPAC_and_INTRANET_staff_client

2. Enable the en-NZ language:
   - In the OPACLanguages system preference -> tick 'English New Zealand
     (en-NZ)' checkbox and untick 'English (en)'

3. Fill in the OverDrive system preferences:
   - Make sure you set: OverDrivePasswordRequired = "Not required"

4. Perform an OPAC search

5. Click on the Overdrive results link

6. Open the browser console and notice there is a JS error, and the
   OverDrive results do not load

7. Apply patch

8. Update the en_NZ translation:

9. Repeat steps 4, 5 and 6 and notice there is no JavaScript error and
   the OverDrive results do display

Sponsored-by: Melbourne Athenaeum Library, Australia

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Comment 3 Owen Leonard 2022-06-14 12:02:42 UTC
There are a couple of other instances that I saw which should also be addressed. I searched the NZ templates for "1[% ELSE %][% END %]"
Comment 4 Katrin Fischer 2022-06-17 20:49:35 UTC
I've filed 

Bug 30991 - [% ELSE %]0[% END %] will break translations if used for assigning variables

for fixing any other occurrences so this can move on.
Comment 5 Katrin Fischer 2022-06-17 20:52:24 UTC
Created attachment 136310 [details] [review]
Bug 30958: OPAC overdrive search result page broken for translations

Note: You will need a valid OverDrive subscription to test this.

This patch fixes a JavaScript error thrown on the OPAC overdrive search
results page for libraries using translation templates and who don't
have the OverDrivePasswordRequired system preference = 'Required'.

Test plan:
1. Install the en-NZ translation: https://wiki.koha-community.org/wiki/Installation_of_additional_languages_for_OPAC_and_INTRANET_staff_client

2. Enable the en-NZ language:
   - In the OPACLanguages system preference -> tick 'English New Zealand
     (en-NZ)' checkbox and untick 'English (en)'

3. Fill in the OverDrive system preferences:
   - Make sure you set: OverDrivePasswordRequired = "Not required"

4. Perform an OPAC search

5. Click on the Overdrive results link

6. Open the browser console and notice there is a JS error, and the
   OverDrive results do not load

7. Apply patch

8. Update the en_NZ translation:

9. Repeat steps 4, 5 and 6 and notice there is no JavaScript error and
   the OverDrive results do display

Sponsored-by: Melbourne Athenaeum Library, Australia

Signed-off-by: Owen Leonard <oleonard@myacpl.org>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 6 Tomás Cohen Arazi (tcohen) 2022-06-21 18:29:30 UTC
Pushed to master for 22.11.

Nice work everyone, thanks!
Comment 7 Lucas Gass (lukeg) 2022-07-15 17:53:58 UTC
Backported to 22.05.x for 22.05.03
Comment 8 Arthur Suzuki 2022-07-21 14:27:35 UTC
backported to 21.11.x for 21.11.11
Comment 9 Victor Grousset/tuxayo 2022-07-24 22:02:52 UTC
Not backported to oldoldstable (21.05.x). Feel free to ask if it's needed.

Nothing to document, marking resolved.
Comment 10 Alex Buckley 2022-07-25 01:15:49 UTC
(In reply to Victor Grousset/tuxayo from comment #9)
> Not backported to oldoldstable (21.05.x). Feel free to ask if it's needed.
> 
> Nothing to document, marking resolved.

Hi Victor, 

We have a client (Melbourne Athenaeum Library - who sponsored this fix) running 21.05.x who would love to have this fix before their next Koha upgrade.

Would it be possible for you to backport this fix to 21.05.x please?

Many thanks!
Alex
Comment 11 Victor Grousset/tuxayo 2022-08-08 22:31:49 UTC
Sure, will try in the next days :)
Comment 12 Alex Buckley 2022-08-09 05:32:46 UTC
(In reply to Victor Grousset/tuxayo from comment #11)
> Sure, will try in the next days :)

Thanks very much Victor :)
Comment 13 Victor Grousset/tuxayo 2022-08-13 15:58:40 UTC
Backported: Pushed to 21.05.x branch for 21.05.18
Comment 14 Alex Buckley 2022-08-30 22:33:19 UTC
(In reply to Victor Grousset/tuxayo from comment #13)
> Backported: Pushed to 21.05.x branch for 21.05.18

Thanks Victor!