From b1a3aeb0624700627a2cb4e1069190e596d50d12 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Fri, 31 Jul 2020 17:19:00 +0000 Subject: [PATCH] Bug 26118: Move translatable strings out of tags/review.tt and into tags-review.js This patch removes the section of the tags review template which defined strings for translation. They can now be embedded in the JavaScript file, wrapped in the __() function. To test, apply the patch and clear your browser cache if necessary. - Go to Tools -> Tags and perform some actions which will trigger the use of translated strings in the interface. For instance: - Approving and rejecting tags - Testing tags which are approved, rejected, or unclassified. - Status messages for these operations should work correctly. TESTING TRANSLATABILITY - Update a translation, e.g. fr-FR: > cd misc/translator > perl translate update fr-FR - Open the corresponding .po file for JavaScript strings, e.g. misc/translator/po/fr-FR-messages-js.po - Locate strings pulled from koha-tmpl/intranet-tmpl/prog/js/pages/tags-review.js for translation, e.g.: msgid "Both subfield values should be filled or empty." msgstr "" - Edit the "msgstr" string however you want (it's just for testing). - Install the updated translation: > perl translate install fr-FR - Switch to your newly translated language in the staff client and repeat the test plan above. The translated strings should appear. Signed-off-by: David Nind Signed-off-by: Katrin Fischer Signed-off-by: Jonathan Druart --- .../prog/en/modules/tags/review.tt | 16 ----------- .../prog/js/pages/tags-review.js | 28 +++++++++---------- 2 files changed, 14 insertions(+), 30 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tags/review.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tags/review.tt index aa052ca7d9..32af227d02 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tags/review.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tags/review.tt @@ -230,22 +230,6 @@ tr > td input,td input[type="submit"] { font-size: 85%; padding: 1px; } [% INCLUDE 'calendar.inc' %] [% Asset.js("lib/jquery/plugins/jquery.checkboxes.min.js") | $raw %] [% Asset.js("js/pages/tags-review.js") | $raw %] - [% END %] [% INCLUDE 'intranet-bottom.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/js/pages/tags-review.js b/koha-tmpl/intranet-tmpl/prog/js/pages/tags-review.js index 7130d2f93f..842ffb9acf 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/pages/tags-review.js +++ b/koha-tmpl/intranet-tmpl/prog/js/pages/tags-review.js @@ -35,22 +35,22 @@ var success_approve = function(tag){ // window.alert(_("AJAX approved tag: ") + tag); }; var failure_approve = function(tag){ - window.alert(MSG_AJAX_APPROVE_FAILED.format(decodeURIComponent( tag ))); + window.alert( __("AJAX failed to approve tag: %s").format(decodeURIComponent(tag)) ); }; var success_reject = function(tag){ // window.alert(_("AJAX rejected tag: ") + tag); }; var failure_reject = function(tag){ - window.alert(MSG_AJAX_REJECTION_FAILED.format(decodeURIComponent( tag ))); + window.alert( __("AJAX failed to reject tag: %s").format(decodeURIComponent(tag)) ); }; var success_test = function(tag){ - $('#verdict').html(MSG_AJAX_TAG_PERMITTED.format( decodeURIComponent( tag ) )); + $('#verdict').html( __("%s is permitted!").format(decodeURIComponent(tag)) ); }; var failure_test = function(tag){ - $('#verdict').html(MSG_AJAX_TAG_PROHIBITED.format( decodeURIComponent( tag ) )); + $('#verdict').html( __("%s is prohibited!").format(decodeURIComponent(tag)) ); }; var indeterminate_test = function(tag){ - $('#verdict').html(MSG_AJAX_TAG_UNCLASSIFIED.format( decodeURIComponent( tag ) )); + $('#verdict').html( __("%s is neither permitted nor prohibited!").format(decodeURIComponent(tag)) ); }; var success_test_call = function() { @@ -69,7 +69,7 @@ $(document).ready(function() { "sPaginationType": "full" })); $('.ajax_buttons' ).css({visibility:"visible"}); - $("p.check").html("
<\/i> "+ LABEL_SELECT_ALL +"<\/a> | <\/i> "+ LABEL_CLEAR_ALL +"<\/a> | "+ LABEL_SELECT_ALL_PENDING +"<\/a><\/div>"); + $("p.check").html("
<\/i> " + __("Select all") + "<\/a> | <\/i> " + __("Clear all") + "<\/a> | " + __("Select all pending") + "<\/a><\/div>"); $("#CheckAll").click(function(){ $(".checkboxed").checkCheckboxes(); return false; @@ -96,12 +96,12 @@ $(document).ready(function() { success: count_approve // success_approve }); $(event.target).next(".rej").prop('disabled', false).css("color","#000"); - $(event.target).next(".rej").html(" " + _("Reject")); + $(event.target).next(".rej").html(" " + __("Reject")); $(event.target).prop('disabled', true).css("color","#666"); - $(event.target).html(" " + LABEL_APPROVED ); + $(event.target).html(" " + __("Approved") ); getelement = $(event.target).data("num"); gettitle = ".status" + getelement; - $(gettitle).text( LABEL_APPROVED ); + $(gettitle).text( __("Approved") ); if ($(gettitle).hasClass("pending") ){ $(gettitle).toggleClass("pending approved"); } else { @@ -116,12 +116,12 @@ $(document).ready(function() { success: count_reject // success_reject }); $(event.target).prev(".ok").prop('disabled', false).css("color","#000"); - $(event.target).prev(".ok").html(" " + LABEL_APPROVE ); + $(event.target).prev(".ok").html(" " + __("Approve")); $(event.target).prop('disabled', true).css("color","#666"); - $(event.target).html(" " + LABEL_REJECTED ); + $(event.target).html(" " + __("Rejected")); getelement = $(event.target).data("num"); gettitle = ".status" + getelement; - $(gettitle).text( LABEL_REJECTED ); + $(gettitle).text( __("Rejected") ); if ($(gettitle).hasClass("pending") ){ $(gettitle).toggleClass("pending rejected"); } else { @@ -130,7 +130,7 @@ $(document).ready(function() { return false; // cancel submit } if ($(event.target).is('#test_button')) { - $(event.target).text( LABEL_TESTING ).prop('disabled', true); + $(event.target).text( __("Testing...") ).prop('disabled', true); $.ajax({ data: { test: $('#test').attr("value") @@ -141,7 +141,7 @@ $(document).ready(function() { } }); $("*").ajaxError(function(evt, request, settings){ - if ((alerted +=1) <= 1){ window.alert(MSG_AJAX_ERROR.format(alerted)); } + if ((alerted +=1) <= 1){ window.alert( __("AJAX error (%s alert)").format(alerted) ); } }); var reviewerField = $("#approver"); -- 2.39.5