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 <david@davidnind.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Owen Leonard 2023-06-15 18:56:25 +00:00 committed by Tomas Cohen Arazi
parent 49e52c3105
commit 85a4779f9a
Signed by: tomascohen
GPG key ID: 0A272EA1B2F3C15F
5 changed files with 5 additions and 24 deletions

View file

@ -143,9 +143,6 @@
</script> </script>
[% Asset.js("js/global.js") | $raw %] [% Asset.js("js/global.js") | $raw %]
[% IF ( OPACAmazonCoverImages || SyndeticsCoverImages ) %] [% IF ( OPACAmazonCoverImages || SyndeticsCoverImages ) %]
<script>
var NO_AMAZON_IMAGE = _("No cover image available");
</script>
[% Asset.js("js/amazonimages.js") | $raw %] [% Asset.js("js/amazonimages.js") | $raw %]
[% END %] [% END %]
@ -194,9 +191,6 @@
var MSG_MULTI_ADD_TAG_FAILED = _("Unable to add one or more tags."); var MSG_MULTI_ADD_TAG_FAILED = _("Unable to add one or more tags.");
var MSG_NO_TAG_SPECIFIED = _("No tag was specified."); var MSG_NO_TAG_SPECIFIED = _("No tag was specified.");
[% END %] [% END %]
[% IF OpenLibraryCovers || OpenLibrarySearch %]
var NO_OL_JACKET = _("No cover image available");
[% END %]
[% IF (query_desc) %] [% IF (query_desc) %]
var query_desc = "[% query_desc | html %]"; var query_desc = "[% query_desc | html %]";
var querystring = "[% querystring | 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 Koha.Preference( 'opacuserlogin' ) == 1 %][% IF Koha.Preference( 'TagsEnabled' ) == 1 %][% Asset.js("js/tags.js") | $raw %][% END %][% END %]
[% IF ( GoogleJackets ) %] [% IF ( GoogleJackets ) %]
[% Asset.js("js/google-jackets.js") | $raw %] [% Asset.js("js/google-jackets.js") | $raw %]
<script>
var NO_GOOGLE_JACKET = _("No cover image available");
</script>
[% END %] [% END %]
[% IF ( Koha.Preference('OpacCoce') && Koha.Preference('CoceProviders') ) %] [% IF ( Koha.Preference('OpacCoce') && Koha.Preference('CoceProviders') ) %]
[% Asset.js("js/coce.js") | $raw %] [% Asset.js("js/coce.js") | $raw %]
@ -260,22 +249,14 @@
[% IF OPACLocalCoverImages %] [% IF OPACLocalCoverImages %]
[% Asset.js("js/localcovers.js") | $raw %] [% Asset.js("js/localcovers.js") | $raw %]
<script>
var NO_LOCAL_JACKET = _("No cover image available");
</script>
[% END %] [% END %]
[% IF ( BakerTaylorEnabled ) %] [% IF ( BakerTaylorEnabled ) %]
[% Asset.js("js/bakertaylorimages.js") | $raw %] [% Asset.js("js/bakertaylorimages.js") | $raw %]
<script> <script>
var NO_BAKERTAYLOR_IMAGE = _("No cover image available");
$(window).load(function(){ $(window).load(function(){
bt_verify_images(); bt_verify_images();
}); });
</script> </script>
[% END %] [% END %]

View file

@ -5,9 +5,9 @@ function verify_images() {
w = this.width; w = this.width;
h = this.height; h = this.height;
if ((w == 1) || (h == 1)) { if ((w == 1) || (h == 1)) {
$(this).parent().html("<span class=\"no-image\">"+NO_AMAZON_IMAGE+"</span>"); $(this).parent().html("<span class=\"no-image\">"+ __("No cover image available") +"</span>");
} else if ((this.complete != null) && (!this.complete)) { } else if ((this.complete != null) && (!this.complete)) {
$(this).parent().html("<span class=\"no-image\">"+NO_AMAZON_IMAGE+"</span>"); $(this).parent().html("<span class=\"no-image\">"+ __("No cover image available") +"</span>");
} }
} }
}); });

View file

@ -4,7 +4,7 @@ function bt_verify_images() {
if (this.src.indexOf('btol.com') >= 0) { if (this.src.indexOf('btol.com') >= 0) {
h = this.height; h = this.height;
if (h == 20) { if (h == 20) {
$(this).before("<span class=\"no-image\" style=\"margin-bottom:5px;width:80px;\">"+NO_BAKERTAYLOR_IMAGE+"</span>"); $(this).before("<span class=\"no-image\" style=\"margin-bottom:5px;width:80px;\">"+ __("No cover image available" ) +"</span>");
} }
} }
}); });

View file

@ -74,7 +74,7 @@ KOHA.Google = {
} else { } else {
var message = document.createElement("span"); var message = document.createElement("span");
$(message).attr("class","no-image"); $(message).attr("class","no-image");
$(message).html(NO_GOOGLE_JACKET); $(message).html(__("No cover image available"));
$(this).empty().append(message); $(this).empty().append(message);
} }
}); });

View file

@ -60,7 +60,7 @@ KOHA.OpenLibrary = new function() {
} else { } else {
var message = document.createElement("span"); var message = document.createElement("span");
$(message).attr("class","no-image"); $(message).attr("class","no-image");
$(message).html(NO_OL_JACKET); $(message).html( __("No cover image available") );
$(this).append(message); $(this).append(message);
} }
}); });