From 85a4779f9a308b5cd8dcde123230d001907a2c10 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Thu, 15 Jun 2023 18:56:25 +0000 Subject: [PATCH] Bug 34026: Move translatable cover-handling strings out of opac-bottom.inc This patch removes several instances from opac-bottom.inc where we define strings for translation and use in separate JavaScript files. The JavaScript files are updated to use the __() function to mark strings for translation. Note: Definition of the variable NO_COCE_JACKET is removed because it is unused. To test, apply the patch and clear your browser cache if necessary. - In the staff interface, enable OPAC cover image services: - OPACAmazonCoverImages - BakerTaylorEnabled - GoogleJackets - OpenLibraryCovers - In the OPAC, perform a search and confirm that there are no JS errors on the search results page related to cover images. - Check the bibliographic detail page as well. To confirm that the strings are being picked up for translation, run the update process for another language, e.g. perl misc/translator/translate update fr-FR Then check the newly-built po file: fr-FR-messages-js.po. It should list the updated files: koha-tmpl/opac-tmpl/bootstrap/js/amazonimages.js:8 koha-tmpl/opac-tmpl/bootstrap/js/amazonimages.js:10 koha-tmpl/opac-tmpl/bootstrap/js/bakertaylorimages.js:7 koha-tmpl/opac-tmpl/bootstrap/js/google-jackets.js:77 koha-tmpl/opac-tmpl/bootstrap/js/openlibrary.js:63 Signed-off-by: David Nind Signed-off-by: Katrin Fischer Signed-off-by: Tomas Cohen Arazi --- .../bootstrap/en/includes/opac-bottom.inc | 19 ------------------- .../opac-tmpl/bootstrap/js/amazonimages.js | 4 ++-- .../bootstrap/js/bakertaylorimages.js | 2 +- .../opac-tmpl/bootstrap/js/google-jackets.js | 2 +- .../opac-tmpl/bootstrap/js/openlibrary.js | 2 +- 5 files changed, 5 insertions(+), 24 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 dbd9bb3e8c..2783019ae7 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc @@ -143,9 +143,6 @@ [% Asset.js("js/global.js") | $raw %] [% IF ( OPACAmazonCoverImages || SyndeticsCoverImages ) %] - [% Asset.js("js/amazonimages.js") | $raw %] [% END %] @@ -194,9 +191,6 @@ var MSG_MULTI_ADD_TAG_FAILED = _("Unable to add one or more tags."); var MSG_NO_TAG_SPECIFIED = _("No tag was specified."); [% END %] - [% IF OpenLibraryCovers || OpenLibrarySearch %] - var NO_OL_JACKET = _("No cover image available"); - [% END %] [% IF (query_desc) %] var query_desc = "[% query_desc | html %]"; var querystring = "[% querystring | html %]"; @@ -243,11 +237,6 @@ [% IF Koha.Preference( 'opacuserlogin' ) == 1 %][% IF Koha.Preference( 'TagsEnabled' ) == 1 %][% Asset.js("js/tags.js") | $raw %][% END %][% END %] [% IF ( GoogleJackets ) %] [% Asset.js("js/google-jackets.js") | $raw %] - [% END %] [% IF ( Koha.Preference('OpacCoce') && Koha.Preference('CoceProviders') ) %] [% Asset.js("js/coce.js") | $raw %] @@ -260,22 +249,14 @@ [% IF OPACLocalCoverImages %] [% Asset.js("js/localcovers.js") | $raw %] - [% END %] [% IF ( BakerTaylorEnabled ) %] [% Asset.js("js/bakertaylorimages.js") | $raw %] [% END %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/js/amazonimages.js b/koha-tmpl/opac-tmpl/bootstrap/js/amazonimages.js index f7b4887e55..acb21518f2 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/js/amazonimages.js +++ b/koha-tmpl/opac-tmpl/bootstrap/js/amazonimages.js @@ -5,9 +5,9 @@ function verify_images() { w = this.width; h = this.height; if ((w == 1) || (h == 1)) { - $(this).parent().html(""+NO_AMAZON_IMAGE+""); + $(this).parent().html(""+ __("No cover image available") +""); } else if ((this.complete != null) && (!this.complete)) { - $(this).parent().html(""+NO_AMAZON_IMAGE+""); + $(this).parent().html(""+ __("No cover image available") +""); } } }); diff --git a/koha-tmpl/opac-tmpl/bootstrap/js/bakertaylorimages.js b/koha-tmpl/opac-tmpl/bootstrap/js/bakertaylorimages.js index 00b025a56d..cda542e277 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/js/bakertaylorimages.js +++ b/koha-tmpl/opac-tmpl/bootstrap/js/bakertaylorimages.js @@ -4,7 +4,7 @@ function bt_verify_images() { if (this.src.indexOf('btol.com') >= 0) { h = this.height; if (h == 20) { - $(this).before(""+NO_BAKERTAYLOR_IMAGE+""); + $(this).before(""+ __("No cover image available" ) +""); } } }); diff --git a/koha-tmpl/opac-tmpl/bootstrap/js/google-jackets.js b/koha-tmpl/opac-tmpl/bootstrap/js/google-jackets.js index 00ca829641..c030fff2d2 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/js/google-jackets.js +++ b/koha-tmpl/opac-tmpl/bootstrap/js/google-jackets.js @@ -74,7 +74,7 @@ KOHA.Google = { } else { var message = document.createElement("span"); $(message).attr("class","no-image"); - $(message).html(NO_GOOGLE_JACKET); + $(message).html(__("No cover image available")); $(this).empty().append(message); } }); diff --git a/koha-tmpl/opac-tmpl/bootstrap/js/openlibrary.js b/koha-tmpl/opac-tmpl/bootstrap/js/openlibrary.js index 41dcfb9fab..ee08b535c1 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/js/openlibrary.js +++ b/koha-tmpl/opac-tmpl/bootstrap/js/openlibrary.js @@ -60,7 +60,7 @@ KOHA.OpenLibrary = new function() { } else { var message = document.createElement("span"); $(message).attr("class","no-image"); - $(message).html(NO_OL_JACKET); + $(message).html( __("No cover image available") ); $(this).append(message); } }); -- 2.39.5