From 006c4db832d90804ca75fd14ba2e710da8ecedea Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Thu, 2 May 2019 16:26:55 +0000 Subject: [PATCH] Bug 22804: OPAC Overdrive JavaScript contains untranslatable strings This patch moves untranslatable strings out of overdrive.js and into opac-bottom.inc where other strings are defined for use in JavaScript files. To test you must have OverDrive integration set up, including OverDriveCirculation. Test the various Overdrive integration features: - Placing holds - Cancelling holds - Checking out - Checking in These features should work as expected. --- .../bootstrap/en/includes/opac-bottom.inc | 11 ++++- koha-tmpl/opac-tmpl/bootstrap/js/overdrive.js | 47 ++++++++++++---------- 2 files changed, 35 insertions(+), 23 deletions(-) diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc index f51f990..f9028d8 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc @@ -134,7 +134,7 @@ $.widget.bridge('uitooltip', $.ui.tooltip); var MSG_CHECKOUTS = _("Checkouts"); var MSG_NO_CHECKOUTS = _("No checkouts"); var MSG_CHECK_OUT = _("Check out"); - var MSG_CHECK_OUT_CONFIRM = _("Are you sure you want to checkout this item?"); + var MSG_CHECK_OUT_CONFIRM = _("Are you sure you want to check out this item?"); var MSG_CHECKED_OUT_UNTIL = _("Checked out until %s"); var MSG_CHECK_IN = _("Check in"); var MSG_CHECK_IN_CONFIRM = _("Are you sure you want to return this item?"); @@ -176,6 +176,15 @@ $.widget.bridge('uitooltip', $.ui.tooltip); var MSG_MULTI_ADD_TAG_FAILED = _("Unable to add one or more tags."); var MSG_NO_TAG_SPECIFIED = _("No tag was specified."); [% END %] + [% IF ( Koha.Preference('OverDriveClientKey') && Koha.Preference('OverDriveClientSecret') ) %] + var MSG_OVERDRIVE_LOGIN = _("Log in to your OverDrive account"); + var MSG_OVERDRIVE_LINK = _( "OverDrive account page" ); + var MSG_OVERDRIVE_LOGOUT = _("Log out from your OverDrive account"); + var MSG_OVERDRIVE_CHECKEDOUT_UNTIL = _( "Checked out until: " ); + var MSG_OVERDRIVE_ACCESS_ONLINE = _("Access online"); + var MSG_OVERDRIVE_DOWNLOAD_AS = _( "Download as: " ); + var MSG_OVERDRIVE_CANNOT_CHECKOUT = _("Item cannot be checked out. There are no available formats"); + [% END %] [% IF ( OPACAmazonCoverImages || SyndeticsCoverImages ) %] $(window).load(function() { verify_images(); diff --git a/koha-tmpl/opac-tmpl/bootstrap/js/overdrive.js b/koha-tmpl/opac-tmpl/bootstrap/js/overdrive.js index 9070dc3..3722163 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/js/overdrive.js +++ b/koha-tmpl/opac-tmpl/bootstrap/js/overdrive.js @@ -1,3 +1,5 @@ +/* global MSG_OVERDRIVE_LOGIN MSG_OVERDRIVE_LINK MSG_OVERDRIVE_LOGOUT MSG_OVERDRIVE_CHECKEDOUT_UNTIL MSG_DOWNLOAD MSG_OVERDRIVE_ACCESS_ONLINE MSG_OVERDRIVE_DOWNLOAD_AS MSG_CHECK_IN MSG_CHECK_OUT MSG_CHECKOUTS MSG_HOLDS MSG_ON_HOLD MSG_PLACE_HOLD MSG_CANCEL_HOLD MSG_OVERDRIVE_CANNOT_CHECKOUT MSG_CANCEL_HOLD_CONFIRM MSG_CHECK_IN_CONFIRM MSG_CHECK_OUT_CONFIRM OD_password_required */ + if ( typeof KOHA == "undefined" || !KOHA ) { var KOHA = {}; } @@ -74,7 +76,7 @@ KOHA.OverDriveCirculation = new function() { if( OD_password_required ) { $("#overdrive-login").modal('show'); } else { login(""); } }) - .text(_("Login to OverDrive account")); + .text( MSG_OVERDRIVE_LOGIN ); var login_div = $('
').append(login_link); @@ -87,6 +89,7 @@ KOHA.OverDriveCirculation = new function() { var checkout_popup = null; $( document ).ready(function() { var p = window.opener; + var cb; if (p) { try { cb = p.refresh_overdrive_account_details;} catch(err){ return; } //Catch error if opener is not accessible @@ -113,7 +116,7 @@ KOHA.OverDriveCirculation = new function() { } var overdrive_link = $('') - .text("OverDrive Account Page"); + .text( MSG_OVERDRIVE_LINK ); $(container).append(overdrive_link); var logout_link = $('') @@ -123,12 +126,12 @@ KOHA.OverDriveCirculation = new function() { logout(function(data) { display_account(container, data); }); - }).text(_("Logout from OverDrive account")); + }).text( MSG_OVERDRIVE_LOGOUT ); $(container).append(logout_link); $(container).append('
'); if (data.checkouts) { - var checkouts_div = $('
').html('

' + _("Checkouts") + '

'); + var checkouts_div = $('
').html('

' + MSG_CHECKOUTS + '

'); var checkouts_list = $('