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 <david@davidnind.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Owen Leonard 2020-07-31 17:19:00 +00:00 committed by Jonathan Druart
parent d2afd19bc3
commit b1a3aeb062
2 changed files with 14 additions and 30 deletions

View File

@ -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 %]
<script>
var MSG_AJAX_APPROVE_FAILED = _("AJAX failed to approve tag: %s");
var MSG_AJAX_REJECTION_FAILED = _("AJAX failed to reject tag: %s");
var MSG_AJAX_TAG_PERMITTED = _("%s is permitted!");
var MSG_AJAX_TAG_PROHIBITED = _("%s is prohibited!");
var MSG_AJAX_TAG_UNCLASSIFIED = _("%s is neither permitted nor prohibited!");
var MSG_AJAX_ERROR = _("AJAX error (%s alert)");
var LABEL_SELECT_ALL = _("Select all");
var LABEL_CLEAR_ALL = _("Clear all");
var LABEL_SELECT_ALL_PENDING = _("Select all pending");
var LABEL_APPROVE = _("Approve");
var LABEL_APPROVED = _("Approved");
var LABEL_REJECT = _("Reject");
var LABEL_REJECTED = _("Rejected");
var LABEL_TESTING = _("Testing...");
</script>
[% END %]
[% INCLUDE 'intranet-bottom.inc' %]

View File

@ -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("<div id=\"searchheader\"><a id=\"CheckAll\" href=\"/cgi-bin/koha/tags/review.pl\"><i class=\"fa fa-check\"><\/i> "+ LABEL_SELECT_ALL +"<\/a> | <a id=\"CheckNone\" href=\"/cgi-bin/koha/tags/review.pl\"><i class=\"fa fa-remove\"><\/i> "+ LABEL_CLEAR_ALL +"<\/a> | <a id=\"CheckPending\" href=\"/cgi-bin/koha/tags/review.pl\"> "+ LABEL_SELECT_ALL_PENDING +"<\/a><\/div>");
$("p.check").html("<div id=\"searchheader\"><a id=\"CheckAll\" href=\"/cgi-bin/koha/tags/review.pl\"><i class=\"fa fa-check\" aria-hidden=\"false\"><\/i> " + __("Select all") + "<\/a> | <a id=\"CheckNone\" href=\"/cgi-bin/koha/tags/review.pl\"><i class=\"fa fa-remove\" aria-hidden=\"false\"><\/i> " + __("Clear all") + "<\/a> | <a id=\"CheckPending\" href=\"/cgi-bin/koha/tags/review.pl\"> " + __("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("<i class='fa fa-remove'></i> " + _("Reject"));
$(event.target).next(".rej").html("<i class='fa fa-remove' aria-hidden='false'></i> " + __("Reject"));
$(event.target).prop('disabled', true).css("color","#666");
$(event.target).html("<i class='fa fa-check'></i> " + LABEL_APPROVED );
$(event.target).html("<i class='fa fa-check' aria-hidden='false'></i> " + __("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("<i class='fa fa-check'></i> " + LABEL_APPROVE );
$(event.target).prev(".ok").html("<i class='fa fa-check' aria-hidden='false'></i> " + __("Approve"));
$(event.target).prop('disabled', true).css("color","#666");
$(event.target).html("<i class='fa fa-remove'></i> " + LABEL_REJECTED );
$(event.target).html("<i class='fa fa-remove' aria-hidden='false'></i> " + __("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");