From 1c49d96ced65cc6fd77cf25a12e439d68351eee7 Mon Sep 17 00:00:00 2001 From: jeremy breuillard Date: Mon, 25 Apr 2022 15:03:32 +0200 Subject: [PATCH] Bug 22490: Some strings in JavaScript files are untranslatable This patch updates the translation functions of the strings in Javascript files Test Plan: 1) Find a string in a popup or from a Javascript file who is still not translated or 1) Home > Administration > Authority types 2) Make sure to have at least one Authority type saved 3) Click on Action > Import 4) Import button without adding any file to trigger the popup 5) The string inside the popup appears without translation 6) Apply patch and repeat from 3) to 5) : now the string is translated --- koha-tmpl/intranet-tmpl/prog/js/authtype.js | 8 ++++---- .../intranet-tmpl/prog/js/background-job-progressbar.js | 2 +- koha-tmpl/intranet-tmpl/prog/js/calendar.js | 2 +- koha-tmpl/intranet-tmpl/prog/js/item_search_fields.js | 2 +- koha-tmpl/intranet-tmpl/prog/js/letter.js | 2 +- koha-tmpl/intranet-tmpl/prog/js/pages/results.js | 6 +++--- koha-tmpl/intranet-tmpl/prog/js/pages/tags-review.js | 4 ++-- koha-tmpl/intranet-tmpl/prog/js/resolve_claim_modal.js | 2 +- koha-tmpl/intranet-tmpl/prog/js/rotating-collections.js | 2 +- koha-tmpl/intranet-tmpl/prog/js/xmlControlfield.js | 2 +- 10 files changed, 16 insertions(+), 16 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/js/authtype.js b/koha-tmpl/intranet-tmpl/prog/js/authtype.js index f1ce1c87f2..9032dfbd8f 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/authtype.js +++ b/koha-tmpl/intranet-tmpl/prog/js/authtype.js @@ -41,7 +41,7 @@ $(document).ready(function() { var filename = $(this).val(); if ( ! /(?:\.csv|\.ods)$/.test(filename)) { $(this).css("background-color","yellow"); - alert(_("Please select a CSV (.csv) or ODS (.ods) spreadsheet file.")); + alert(__("Please select a CSV (.csv) or ODS (.ods) spreadsheet file.")); $(this).val(""); $(this).css("background-color","white"); } @@ -56,9 +56,9 @@ $(document).ready(function() { var id = $(this).attr('id'); var obj = $('#' + id + ' input:file'); if (/(?:\.csv|\.ods)$/.test(obj.val())) { - if (confirm(_("Do you really want to import the authority type fields and subfields? This will overwrite the current configuration. For safety reasons please use the export option to make a backup"))) { + if (confirm(__("Do you really want to import the authority type fields and subfields? This will overwrite the current configuration. For safety reasons please use the export option to make a backup"))) { var authtypecode = $('#' + id + ' input:hidden[name=authtypecode]').val(); - $('#importing_' + authtypecode).find("span").html(_("Importing to authority type: %s. Importing from file: %s").format("" + authtypecode + "", "" + obj.val().replace(new RegExp("^.+[/\\\\]"),"") + "")); + $('#importing_' + authtypecode).find("span").html(__("Importing to authority type: %s. Importing from file: %s").format("" + authtypecode + "", "" + obj.val().replace(new RegExp("^.+[/\\\\]"),"") + "")); if (navigator.userAgent.toLowerCase().indexOf('msie') != -1) { var timestamp = new Date().getTime(); $('#importing_' + authtypecode).find("img").attr('src', '[% interface | html %]/[% theme | html %]/img/loading-small.gif' + '?' +timestamp); @@ -73,7 +73,7 @@ $(document).ready(function() { } } obj.css("background-color","yellow"); - alert(_("Please select a CSV (.csv) or ODS (.ods) spreadsheet file.")); + alert(__("Please select a CSV (.csv) or ODS (.ods) spreadsheet file.")); obj.val(""); bj.css("background-color","white"); return false; diff --git a/koha-tmpl/intranet-tmpl/prog/js/background-job-progressbar.js b/koha-tmpl/intranet-tmpl/prog/js/background-job-progressbar.js index 5ddb4053c2..52ee7380e4 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/background-job-progressbar.js +++ b/koha-tmpl/intranet-tmpl/prog/js/background-job-progressbar.js @@ -69,7 +69,7 @@ function submitBackgroundJob(f) { backgroundJobProgressTimer = setInterval("updateJobProgress()", 500); }, error: function(xml, textStatus) { - humanMsg.displayMsg( '

' + _('Import of record(s) failed: ') + textStatus + '


'+xml.responseText, { className: 'humanError' } ); + humanMsg.displayMsg( '

' + __('Import of record(s) failed: ') + textStatus + '


'+xml.responseText, { className: 'humanError' } ); } }); diff --git a/koha-tmpl/intranet-tmpl/prog/js/calendar.js b/koha-tmpl/intranet-tmpl/prog/js/calendar.js index 7a4a5083e8..9cf118d94f 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/calendar.js +++ b/koha-tmpl/intranet-tmpl/prog/js/calendar.js @@ -114,7 +114,7 @@ function DateTime_from_syspref(date_time) { }, messages: { input_name_of_later_date_field: { - is_date_after: _("Validation error to be shown, i.e. End date must come after start date") + is_date_after: __("Validation error to be shown, i.e. End date must come after start date") } } }); diff --git a/koha-tmpl/intranet-tmpl/prog/js/item_search_fields.js b/koha-tmpl/intranet-tmpl/prog/js/item_search_fields.js index 33d6c25058..92c98f3027 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/item_search_fields.js +++ b/koha-tmpl/intranet-tmpl/prog/js/item_search_fields.js @@ -2,7 +2,7 @@ jQuery.validator.addMethod("marcfield", function(value, element) { return this.optional(element) || /^[0-9a-zA-Z]+$/.test(value); -}, _("Please enter letters or numbers") ); +}, __("Please enter letters or numbers") ); $(document).ready(function(){ $("#add_field_form").hide(); diff --git a/koha-tmpl/intranet-tmpl/prog/js/letter.js b/koha-tmpl/intranet-tmpl/prog/js/letter.js index 84e63c9d96..cc7cb3c109 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/letter.js +++ b/koha-tmpl/intranet-tmpl/prog/js/letter.js @@ -120,7 +120,7 @@ $(document).ready(function() { $(".content_sms").on("keyup", function(){ var length = $(this).val().length; var sms_counter = ("#sms_counter_" + $(this).data('lang')); - $(sms_counter).html(length + "/" + sms_limit + _(" characters")); + $(sms_counter).html(length + "/" + sms_limit + __(" characters")); if ( length > sms_limit ) { $(sms_counter).css("color", "red"); } else { diff --git a/koha-tmpl/intranet-tmpl/prog/js/pages/results.js b/koha-tmpl/intranet-tmpl/prog/js/pages/results.js index 5320b3b3af..e901c629aa 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/pages/results.js +++ b/koha-tmpl/intranet-tmpl/prog/js/pages/results.js @@ -54,11 +54,11 @@ function verify_cover_images() { if( div.hasClass("coce-coverimg") ){ /* Identify which service's image is being loaded by IntranetCoce system pref */ if( $(img).attr("src").indexOf('amazon.com') >= 0 ){ - div.find(".hint").html(_("Coce image from Amazon.com")); + div.find(".hint").html(__("Coce image from Amazon.com")); } else if( $(img).attr("src").indexOf('google.com') >= 0 ){ - div.find(".hint").html(_("Coce image from Google Books")); + div.find(".hint").html(__("Coce image from Google Books")); } else if( $(img).attr("src").indexOf('openlibrary.org') >= 0 ){ - div.find(".hint").html(_("Coce image from Open Library")); + div.find(".hint").html(__("Coce image from Open Library")); } else { blanks.push( coverId ); div.remove(); 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 fb790551bd..f2bb3521d7 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/pages/tags-review.js +++ b/koha-tmpl/intranet-tmpl/prog/js/pages/tags-review.js @@ -38,7 +38,7 @@ var failure_approve = function(tag){ window.alert( __("AJAX failed to approve tag: %s").format(decodeURIComponent(tag)) ); }; var success_reject = function(tag){ - // window.alert(_("AJAX rejected tag: ") + tag); + // window.alert(__("AJAX rejected tag: ") + tag); }; var failure_reject = function(tag){ window.alert( __("AJAX failed to reject tag: %s").format(decodeURIComponent(tag)) ); @@ -55,7 +55,7 @@ var indeterminate_test = function(tag){ var success_test_call = function() { $('#test_button').prop('disabled', false); - $('#test_button').html("" +_(" Test")); + $('#test_button').html("" +__(" Test")); }; $(document).ready(function() { diff --git a/koha-tmpl/intranet-tmpl/prog/js/resolve_claim_modal.js b/koha-tmpl/intranet-tmpl/prog/js/resolve_claim_modal.js index c59ee023e5..9df74f6d01 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/resolve_claim_modal.js +++ b/koha-tmpl/intranet-tmpl/prog/js/resolve_claim_modal.js @@ -5,7 +5,7 @@ $('body').on('click', '.return-claim-tools-resolve', function() { $('#claims-returned-resolved-modal-id').val(id); $("#new_lost_status").val(current_lost_status); let selected_option = $("#new_lost_status option:selected"); - $(selected_option).text(_("%s (current status)").format($(selected_option).text())); + $(selected_option).text(__("%s (current status)").format($(selected_option).text())); $('#claims-returned-resolved-modal').modal() }); diff --git a/koha-tmpl/intranet-tmpl/prog/js/rotating-collections.js b/koha-tmpl/intranet-tmpl/prog/js/rotating-collections.js index e7869382bf..91871a469e 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/rotating-collections.js +++ b/koha-tmpl/intranet-tmpl/prog/js/rotating-collections.js @@ -5,7 +5,7 @@ $(document).ready(function(){ $(".confirmdelete").click(function(){ $(this).parents('tr').addClass("warn"); - if(confirm(_("Are you sure you want to delete this rotating collection?"))){ + if(confirm(__("Are you sure you want to delete this rotating collection?"))){ return true; } else { $(this).parents('tr').removeClass("warn"); diff --git a/koha-tmpl/intranet-tmpl/prog/js/xmlControlfield.js b/koha-tmpl/intranet-tmpl/prog/js/xmlControlfield.js index d995bda23f..25acae56fa 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/xmlControlfield.js +++ b/koha-tmpl/intranet-tmpl/prog/js/xmlControlfield.js @@ -212,7 +212,7 @@ function changeH4Result(form, h4_result, tr_result, pos, value) }).responseXML; if (this.xmlDoc) this.renderTemplate(); $("*").ajaxError(function(evt, request, settings){ - alert(_("AJAX error: receiving data from %s").format(settings.url)); + alert(__("AJAX error: receiving data from %s").format(settings.url)); }); },//loadXmlValues -- 2.17.1